python2.7与3.5中input的差别

在2.7中
input输入的数值
raw_input输入的事字符串
或者把输入的内容用引号扩起来  
deathage = 80
name = raw_input("your name:")
age = input("your age:")
print "hi,",name,"your age is ",age,"now."
print "you can still live for ",deathage-age," years."
在3.5中
input输入的都是字符串
数值要在输入后转化成数值类型:
deathage = 80
name = input("your name:")
age = input("your age:")
print "hi,",name,"your age is ",age,"now."
print "you can still live for ",deathage-int(age)," years."
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值