Python实现猜数字游戏1.0版

"""
功能:
随机生成一个数字,最多有3次猜测机会,如果第一次没有猜对,则从第二次猜测开始会提示玩家所猜的数字是大了还是小了。
运行环境:
Python 3
"""
import random    #调用生成随机数的模块random
secret = random.randint(1,10)    #调用random模块中生成整型随机数的函数randint,生成的随机数范围在1到10之间,包括1和10.
print('-----猜数字游戏1.0版--------')
temp = input("猜一下我现在想的是哪个数字吧,你只有3次机会哦:")
guess = int(temp)
i = 0
if (guess == secret):
    print("第一次就猜对了,好厉害!!!")
while (guess != secret) and (i < 2):
    temp = input("猜错啦,再猜一次吧:")
    guess = int(temp)
    if guess == secret:
        print("Wow!你猜的真准!")
    else:
        if guess < secret:
            print("猜的小了")
        else:
            print("猜的大了")
    i = i+1

Python报错:SyntaxError: Non-ASCII character ‘\xe5’ in file 1.py on line 6, but no encoding declared…

具体报错内容:

File "1.py", line 6
SyntaxError: Non-ASCII character '\xe5' in file 1.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

继续阅读“Python报错:SyntaxError: Non-ASCII character ‘\xe5’ in file 1.py on line 6, but no encoding declared…”