自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Python讀取輸入值相關(guān)應(yīng)用技巧分享

開發(fā) 后端
Python讀取輸入值的應(yīng)用可以使用python raw_input的操作來實現(xiàn)。那么在這里,我們會針對這一應(yīng)用技巧做一個詳細的介紹。

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

下面介紹了python raw_input的用法,使用raw_input 能夠很方便的叢控制臺讀入數(shù)據(jù)。

Python讀取輸入值操作方法1.輸入字符串

  1. #13222319810101****  
  2. nID = '' 
  3. while 1:  
  4. nID = raw_input("Input your id plz")  
  5. if len(nID) != len("13222319810101****"):  
  6. print 'wring length of id,input again'  
  7. else:  
  8. break  
  9. print 'your id is %s' % (nID) 

Python讀取輸入值操作方法2.輸入整數(shù)

  1. nAge = int(raw_input("input your age plz:\n"))  
  2. if nAge > 0 and nAge < 120: 
  3. print 'thanks!'  
  4. else:  
  5. print 'bad age'  
  6. print 'your age is %d\n' % nAge 

Python讀取輸入值操作方法3.輸入浮點型

  1. fWeight = 0.0  
  2. fWeight = float(raw_input("input your weight\n"))  
  3. print 'your weight is %f' % fWeight 

Python讀取輸入值操作方法4.輸入16進制數(shù)據(jù)

  1. nHex = int(raw_input('input hex value(like 0x20):\n'),16)  
  2. print 'nHex = %x,nOct = %d\n' %(nHex,nHex) 

Python讀取輸入值操作方法5.輸入8進制數(shù)據(jù)

  1. nOct = int(raw_input('input oct value(like 020):\n'),8)  
  2. print 'nOct = %o,nDec = %d\n' % (nOct,nOct) 

【編輯推薦】

  1. Python自動下載文件正確操作方法
  2. Python大小寫正確應(yīng)用方法詳解
  3. Python實現(xiàn)WEB實際測試方法介紹
  4. Python操作Access數(shù)據(jù)庫基本操作步驟分析
  5. Python yield具體使用方法探討
責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2009-12-29 16:08:41

Silverlight

2009-12-30 10:25:03

Silverlight

2010-01-28 10:55:14

Android電源管理

2010-02-05 13:44:06

C++ eof()函數(shù)

2010-03-04 10:50:45

windows ser

2010-02-03 15:35:00

C++輸入輸出漢字

2010-01-25 18:33:35

Android鍵盤操作

2009-12-10 17:27:39

PHP操作Cookie

2010-02-22 17:58:06

WCF異步上傳

2009-12-15 10:23:23

Ruby應(yīng)用技巧

2010-02-05 17:25:26

C++標(biāo)識符命名規(guī)則

2009-12-30 13:37:24

Silverlight

2010-01-06 17:02:28

.Net Framew

2010-02-24 11:22:04

WCF方法重載

2010-01-28 14:12:20

Android Act

2010-01-25 11:09:58

Android Htt

2010-01-18 14:08:29

VB.NET類型轉(zhuǎn)換

2009-12-30 18:23:13

Silverlight

2009-12-29 17:56:47

Silverlight

2010-02-06 10:24:48

C++二維數(shù)組初始化
點贊
收藏

51CTO技術(shù)棧公眾號