python3獲取控制臺輸入的數據的方法:可以利用input()函數來獲取。
python3為我們提供了input()函數,該函數用來接收一個標準輸入數據,返回為string類型,使用方法如:【age = input()】。
Python3.x 中 提供了 input() 函數接受一個標準輸入數據,返回為 string 類型。
語法:
1
|
input ([prompt]) |
參數prompt表示提示信息。
代碼示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
""" 接收控制臺的輸入 How old are you? 18 How tall are you ? 180 How much do you weigh? 50 So ,you are '18' old,'180' tall and '50' heavy, python3的控制臺輸入函數時input(); """ print ( "How old are you?" ); age = input (); print ( "How tall are you ?" ); height = input (); print ( "How much do you weigh?" ); weight = input (); print ( "So ,you are %r old,%r tall and %r heavy," % (age,height,weight)); |
內容擴展:
Python控制臺是什么?
Python 控制臺是一種執行命令的快速方法,可以訪問完整的Python API、查詢命令歷史記錄和自動補全。
命令提示符是 Python 3.x 的典型操作,加載解釋器,并在提示符 >>> 處接受命令。
Python 控制臺是內置的用于探索Blender 的可能性的絕佳方法。Python 控制臺可用于測試小段 python,然后粘貼到更大的腳本中。
以上就是python3獲取控制臺輸入的數據的具體實例的詳細內容,更多關于python3如何獲取控制臺輸入的數據的資料請關注服務器之家其它相關文章!
原文鏈接:https://www.py.cn/jishu/jichu/19858.html