1 | message = input("Tell me something, and I will repeat it back to you: ") |
使用 input() 时,Python将用户输入解读为字符串。 如果要使用数值,需要用 int() 函数转换。
值得注意的是:
在 Python2.7 中,输入应该用raw_input()函数,这与Python3中的 input() 等效。Python2.7 也包含 input() 函数,但它将用户输入解读为Python代码。
1 | a = input() |