马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
import os
def main():
while True:
How_many = []
many = 1
robot_num = random.randint(1,100)
j = True
print('-' * 20 + '我爱鱼C' + '-' * 20)
print('='*47)
while j:
try:
num = input('请输入数字:')
num_int = int(num)
except ValueError:
if num.isalpha():
if is_Chinese(num):
print('请不要输入字母和汉字')
else:
print('请不要输入字母')
elif num.isalnum():
if is_Chinese(num):
print('请不要输出字母和数字和汉字的组合')
else:
print('请不要输出字母和数字的组合')
else:
pass
if robot_num == num_int:
print(f'{many}次猜对,牛逼')
How_many.append('次数:')
How_many.append(many)
j = False
elif robot_num > num_int:
print('小了小了')
many = many + 1
elif robot_num < num_int:
print('大了大了')
def is_Chinese(word):
for ch in word:
if '\u4e00' <= ch <= '\u9fff':
return True
return False
if __name__ == '__main__':
main()
|