新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:python3怎么獲取控制臺(tái)輸入的數(shù)據(jù)
Python3獲取控制臺(tái)輸入的數(shù)據(jù)的方法:可以利用input()函數(shù)來獲取。python3為我們提供了input()函數(shù),該函數(shù)用來接收一個(gè)標(biāo)準(zhǔn)輸入數(shù)據(jù),返回為string類型,使用方法如:【age = input()】。

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供合浦網(wǎng)站建設(shè)、合浦做網(wǎng)站、合浦網(wǎng)站設(shè)計(jì)、合浦網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、合浦企業(yè)網(wǎng)站模板建站服務(wù),十年合浦做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
Python3.x 中 提供了 input() 函數(shù)接受一個(gè)標(biāo)準(zhǔn)輸入數(shù)據(jù),返回為 string 類型。
(推薦教程:Python入門教程)
語法:
input([prompt])
參數(shù)prompt表示提示信息。
代碼示例:
"""
接收控制臺(tái)的輸入
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的控制臺(tái)輸入函數(shù)時(shí)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)); 當(dāng)前標(biāo)題:創(chuàng)新互聯(lián)Python教程:python3怎么獲取控制臺(tái)輸入的數(shù)據(jù)
標(biāo)題來源:http://m.5511xx.com/article/codocdj.html


咨詢
建站咨詢
