标签:随机 imp random int ESS guess 数字 程序 try
#test 猜数字#coding:utf-8
import random
num = random.randint(0,100)
#print(num)
while True:
try:
guess = int(input("请输入一个1~100的随机数:"))
except ValueError as err:
print("Enter 1~100", err)
continue
if guess > num:
print("%d greater random number" %(guess))
elif guess < num:
print("%d smaller random number" %(guess))
else:
print("guess bingo,game over!")
break
print("\n")
标签:随机 imp random int ESS guess 数字 程序 try
原文地址:http://blog.51cto.com/huwho/2167600