新聞中心
Python編程語言中有一種應(yīng)用可以對輸入值進行讀取,這一應(yīng)用在實際操作中是非常重要的應(yīng)用技術(shù)。在這里,我們將會為大家詳細介紹一下有關(guān)Python讀取輸入值的相關(guān)應(yīng)用技巧,希望可以給大家?guī)硇椭?/p>

創(chuàng)新互聯(lián)建站專注于企業(yè)網(wǎng)絡(luò)營銷推廣、網(wǎng)站重做改版、安陸網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5建站、成都商城網(wǎng)站開發(fā)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為安陸等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
下面介紹了python raw_input的用法,使用raw_input 能夠很方便的叢控制臺讀入數(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.輸入浮點型
- fWeight = 0.0
- fWeight = float(raw_input("input your weight\n"))
- print 'your weight is %f' % fWeight
Python讀取輸入值操作方法4.輸入16進制數(shù)據(jù)
- nHex = int(raw_input('input hex value(like 0x20):\n'),16)
- print 'nHex = %x,nOct = %d\n' %(nHex,nHex)
Python讀取輸入值操作方法5.輸入8進制數(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)用技巧分享
文章網(wǎng)址:http://m.5511xx.com/article/ccopgpj.html


咨詢
建站咨詢
