Python3 input() 函數(shù)

2019-03-25 14:09 更新

Python3 input() 函數(shù)

Python3 內(nèi)置函數(shù) Python3 內(nèi)置函數(shù)

Python3.x 中 input() 函數(shù)接受一個(gè)標(biāo)準(zhǔn)輸入數(shù)據(jù),返回為 string 類(lèi)型。

注意:在 Python3.x 中 raw_input() 和 input() 進(jìn)行了整合,去除了 raw_input( ),僅保留了input( )函數(shù),其接收任意任性輸入,將所有輸入默認(rèn)為字符串處理,并返回字符串類(lèi)型。

語(yǔ)法

input([prompt])

參數(shù)說(shuō)明:

  • prompt: 提示信息

實(shí)例

input() 需要輸入python 表達(dá)式:

>>>a = input("input:")
input:123 # 輸入整數(shù)
>>> type(a)
<class 'str'> # 字符串
>>> a = input("input:")
input:w3cschool # 正確,字符串表達(dá)式
>>> type(a)
<class 'str'> # 字符串

更多內(nèi)容

Python2.x input 與 raw_input() 說(shuō)明

Python3 內(nèi)置函數(shù) Python3 內(nèi)置函數(shù)

以上內(nèi)容是否對(duì)您有幫助:
在線(xiàn)筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)