Python3 input() 函數


Python3 input() 函數

Python3 內置函數 Python3 內置函數

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:runoob # 正確,字符串表達式 >>> type(a) <class 'str'> # 字符串


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM