python 用户交互


这里来一个用户交互,并判断用户输出姓名,得到不同回应。
将姓名加上颜色显示。
 
 
#coding:utf-8

name = raw_input('what is your name?:')
age = raw_input('how old are you?:')
job = raw_input('what is your job?:')
msg = """
Information of %s as below:
        Name : \033[42;1m%s \033[0m
        Age  : %s
        Job  : %s
""" %(name,name,age,job)
if int(age) >= 50:
        print "you are too old,you can only work"
elif int (age) >=30:
        print "you are too old, you can only work for ..."
elif int (age) >20:
        print "you wei cheng nian"
else:
        print "old your xia"
print msg

 

//说明一下,其实没啥好说的,很简单,不说了。

评论关闭