新聞中心
Python編程語(yǔ)言中有一種應(yīng)用可以對(duì)輸入值進(jìn)行讀取,這一應(yīng)用在實(shí)際操作中是非常重要的應(yīng)用技術(shù)。在這里,我們將會(huì)為大家詳細(xì)介紹一下有關(guān)Python讀取輸入值的相關(guān)應(yīng)用技巧,希望可以給大家?guī)?lái)些幫助。

創(chuàng)新互聯(lián)建站專(zhuān)注于企業(yè)網(wǎng)絡(luò)營(yíng)銷(xiāo)推廣、網(wǎng)站重做改版、安陸網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5建站、成都商城網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為安陸等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
下面介紹了python raw_input的用法,使用raw_input 能夠很方便的叢控制臺(tái)讀入數(shù)據(jù)。
Python讀取輸入值操作方法1.輸入字符串
- #13222319810101****
- nID = ''
- while 1:
- nID = raw_input("Input your id plz")
- if len(nID) != len("13222319810101****"):
- print 'wring length of id,input again'
- else:
- break
- print 'your id is %s' % (nID)
Python讀取輸入值操作方法2.輸入整數(shù)
- nAge = int(raw_input("input your age plz:\n"))
- if nAge > 0 and nAge < 120:
- print 'thanks!'
- else:
- print 'bad age'
- print 'your age is %d\n' % nAge
Python讀取輸入值操作方法3.輸入浮點(diǎn)型
- fWeight = 0.0
- fWeight = float(raw_input("input your weight\n"))
- print 'your weight is %f' % fWeight
Python讀取輸入值操作方法4.輸入16進(jìn)制數(shù)據(jù)
- nHex = int(raw_input('input hex value(like 0x20):\n'),16)
- print 'nHex = %x,nOct = %d\n' %(nHex,nHex)
Python讀取輸入值操作方法5.輸入8進(jìn)制數(shù)據(jù)
- nOct = int(raw_input('input oct value(like 020):\n'),8)
- print 'nOct = %o,nDec = %d\n' % (nOct,nOct)
新聞名稱:Python讀取輸入值相關(guān)應(yīng)用技巧分享
新聞來(lái)源:http://fisionsoft.com.cn/article/ccopgpj.html


咨詢
建站咨詢
