控制码如下:
编写python程序:
song@ubuntu:~$ vi ex3.py
song@ubuntu:~$ more ex3.py
#!/usr/bin/env python
#_*_ coding:utf-8 _*_
real_age=28
for i in range(3):
age=input('Please input the age:')
if age>real_age:
print '\033[31;1mtoo big,please think smaller!\033[0m'
elif age<real_age:
print '\033[42;1mtoo small,please think bigger!\033[0m'
else:
print '\033[33;1mGood,you guess right!!!\033[0m'
break
print 'you have still %s shots' % (2-i)
song@ubuntu:~$
运行结果,如下图:
(完)