使用 input() 和 raw input()

Python 2.x >= 2.3

raw_input 將等待使用者輸入文字,然後將結果作為字串返回。

foo = raw_input("Put a message here that asks the user for input")

在上面的示例中,foo 將儲存使用者提供的任何輸入。

Python 3.x >= 3.0

input 將等待使用者輸入文字,然後將結果作為字串返回。

foo = input("Put a message here that asks the user for input")

在上面的示例中,foo 將儲存使用者提供的任何輸入。