您的位置:首页 > 编程语言 > Python开发

第四节:python if语句用法

2016-10-13 08:38 656 查看
name=raw_input('pelase input your name:')
age=raw_input('pelase input your age:')
job=raw_input(pelase input your jobs:)
test= """
name : %s
age    : %s
job     : %s
""" %(name,age,job)

print test

print type(age)  #测试输入的字符类型。

if int(age)>=30:
print "you are too old!"
else:
print "you are very young!"

重点:
age=int(raw_input('pelase input your age:'))
int(age)的用法:强制转换字符串为数字大小。str为字符串,int为数字大小。

age  = raw_input('pelase input your age:').strip()
print len(age)

.strip()跳过空格的用法。
print len(age)统计字符串长度的用法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  字符串 python