《笨方法学 Python 3》12.提示别人---input()

基础练习:

    你可以在input()之间放入提示符,告诉别人应该输入什么。

    如下所示:x = input("Name?"),这句话会用“Name?”来提示用户应该输入什么,然后将用户输入的内容赋值给变量x。

    然后我们将上个习题重新写一次:

age = input("How old are you? ")
height = input("How tall are you? ")
weight = input("How much do you heavy? ")

print(f"So, you're {age} years old, {height} tall and {weight} heavy.")

答案:   

注意: 上面input()最后都加个空格,这个让代码更加美观。否则就会显示成这样,感觉必要拥挤;

猜你喜欢

转载自blog.csdn.net/waitan2018/article/details/82261528