新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python讀取輸入值相關應用技巧分享
Python編程語言中有一種應用可以對輸入值進行讀取,這一應用在實際操作中是非常重要的應用技術。在這里,我們將會為大家詳細介紹一下有關Python讀取輸入值的相關應用技巧,希望可以給大家?guī)硇椭?/p>

創(chuàng)新互聯(lián)建站專注于企業(yè)網(wǎng)絡營銷推廣、網(wǎng)站重做改版、安陸網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、HTML5建站、成都商城網(wǎng)站開發(fā)、集團公司官網(wǎng)建設、成都外貿(mào)網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為安陸等各大城市提供網(wǎng)站開發(fā)制作服務。
下面介紹了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讀取輸入值相關應用技巧分享
網(wǎng)站URL:http://www.5511xx.com/article/ccopgpj.html


咨詢
建站咨詢
