标签:style blog color ar div 时间 log python
1 #Filename:game1.py 2 3 guess=10 4 running=True 5 while running: 6 try: 7 answer=int(raw_input(‘Guess what i think:‘)) 8 except: 9 print ‘Please input interga\n‘ 10 continue 11 12 if answer<guess: 13 print ‘Your answer is too small\n‘ 14 continue 15 elif answer>guess: 16 print ‘Your answer is too large\n‘ 17 continue 18 else: 19 print ‘BINGO‘ 20 break 21 22 print ‘\nDone‘
学习python有一段时间了,回头把第一章看到的猜数字游戏写了下,加入了捕获异常,更加的强壮。
python写的第一个简单小游戏-猜数字,布布扣,bubuko.com
标签:style blog color ar div 时间 log python
原文地址:http://www.cnblogs.com/liyiran/p/3899393.html