首页 > 代码库 > python写的第一个简单小游戏-猜数字

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\n10             continue11         12         if answer<guess:13                print Your answer is too small\n14                continue15         elif answer>guess:16                print Your answer is too large\n17                continue18         else:19                print BINGO20                break21 22 print \nDone

学习python有一段时间了,回头把第一章看到的猜数字游戏写了下,加入了捕获异常,更加的强壮。