跳至内容
Python 俱乐部
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
python-basic:raw-input
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Python raw_input 读取输入值 ====== 下面介绍了python raw_input的用法,\\ 使用raw_input 能够很方便的丛控制台读入数据。\\ ===== 1.输入字符串 ===== <code python> #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) </code> ===== 2.输入整数 ===== <code python> 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 </code> ===== 3.输入浮点型 ===== <code python> fWeight = 0.0 fWeight = float(raw_input("input your weight\n")) print 'your weight is %f' % fWeight </code> ===== 4.输入16进制数据 ===== <code python> nHex = int(raw_input('input hex value(like 0x20):\n'),16) print 'nHex = %x,nOct = %d\n' %(nHex,nHex) </code> ===== 5.输入8进制数据 ===== <code python> nOct = int(raw_input('input oct value(like 020):\n'),8) print 'nOct = %o,nDec = %d\n' % (nOct,nOct) </code> ===== 补充材料 ===== * [[python-basic:input|raw_input和input的区别]]
python-basic/raw-input.txt
· 最后更改: 2010/12/28 02:02 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部