笨方法学python-习题12
代码:
age = input("How old are you? ")
height = input("How tall are you? ")
weight = input("How much do you weigh? ")
print(f"So, you're {age} old, {height} tall and {weight} heavy.")
结果
How old are you? age
How tall are you? height_
How much do you weigh? weight_
So, you're age old, height_ tall and weight_ heavy.
知识点:
我发现了一个有趣的事情,我输入是什么内容,就会打印什么内容,无论输入的内容是否是数字,另外,input括号里面的字符串输出后,竟然不会换行,我输入内容后,按回车才会进行换行。
另外,书上提到的在 Terminal 里输入 pydoc input
,看看它会说什么。如果你用的是 Windows, 输入 python3.6 -m pydoc input
。
我在vscode中输入会出现问题,我安装的python3.9.12,我输入python3.9.12 -m pydoc input
会报错,最后输入python -m pydoc input
才成功,内容如下图所示。