范玮琪歌曲百度云资源:Python raw_input 读取输入值 [Python俱乐部]
来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 15:13:19
Python raw_input 读取输入值
下面介绍了python raw_input的用法,
使用raw_input 能够很方便的丛控制台读入数据。
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)
2.输入整数
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
3.输入浮点型
fWeight = 0.0
fWeight = float(raw_input("input your weight\n"))
print 'your weight is %f' % fWeight
4.输入16进制数据
nHex = int(raw_input('input hex value(like 0x20):\n'),16)
print 'nHex = %x,nOct = %d\n' %(nHex,nHex)
5.输入8进制数据
nOct = int(raw_input('input oct value(like 020):\n'),8)
print 'nOct = %o,nDec = %d\n' % (nOct,nOct)
补充材料
- raw_input和input的区别
Python raw_input 读取输入值 [Python俱乐部]
Python 读取DBF/FPT 文件 [Python俱乐部]
Python input和raw_input的区别 [Python俱乐部]
Python
python
Python读取二进制文件 --- webpro程序爱好者 asp,asp.net,jav...
[Python]python随笔
[Python]Python笔记-
[Python]python编程 FAQ
python 数列
[Python]C#程序员初学Python
[Python]Python连接MySQL (例子)
[Python]python for ARM/LINUX
[Python]MySQLdb for Python使用指南
[Python]用Python操作Mysql
[Python]年度黑马Python 自省指南
[Python]Python完全新手教程 -- 1
[Python]Python完全新手教程 -- 2
[Python]Python完全新手教程 -- 3
[Python]用Python开发MySQL脚本
[Python]python get,post提交表单
[Python]网站开发深入浅出 - Python篇
[Python]Python的ARM-Linux平台移植
python-memcached: Python API for memcached