Python3 input() 函數
Python3.x 中 input() 函數接受一個標準輸入數據,返回為 string 類型。
注意:在 Python3.x 中 raw_input() 和 input() 進行了整合,去除了 raw_input( ),僅保留了input( )函數,其接收任意任性輸入,將所有輸入默認為字串處理,並返回字串類型。
函數語法
input([prompt])
參數說明:
- prompt: 提示資訊
實例
input() 需要輸入 python 運算式
>>>a = input("input:")
input:123 # 輸入整數
>>> type(a)
<class 'str'> # 字串
>>> a = input("input:")
input:zaixian # 正確,字串運算式
>>> type(a)
<class 'str'> # 字串
更多內容
Python2.x input 與 raw_input() 說明