标签:python else 测试 转型 input compare print int 数字
## 输入name
##name = input(‘What is your name ‘)
name = ‘stan‘
## test for if,elif
if name == ‘stan‘:
print(‘1. yes , your are stan‘ )
print(‘here is if‘)
elif name == ‘vanees‘:
print(‘2. not stan, you are vanees‘ )
print(‘here is elif‘)
else:
print(‘9. other people , your name is‘, name )
print(‘here is else‘)
##注意数字转型
tnum = input (‘compare with 5 ,number is ‘)
##此时t_num为string,需要转型为int
tnums = int(tnum)
if tnums<5:
print(‘tnum<5, it is‘,tnums)
else:
print(‘tnum>=5, it is‘,tnums)
标签:python else 测试 转型 input compare print int 数字
原文地址:http://www.cnblogs.com/dcbook/p/7516333.html