2017-03-17 49 views
0

我看到下面的错误:“非ASCII字符”错误时,从Windows PowerShell中运行的Python程序

SyntaxError: Non-ASCII character '\x93' in file new2.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details 

当我运行这段代码:

print(“Welcome") 
guess = 0 
while guess != 5: 
    g = input(“Guess the number: ") 
    guess = int(g) 
    if guess == 5: 
    print(“You win!") 
    else: 
    if guess > 5: 
    print(“Too high") 
    else: 
    print(“Too low") 
print(“Game over!") 
+1

''''应该是什么符号?在'g = input(“猜测数字:”)'这一行' - 与你的'print'语句相同 – UnholySheep

+3

你的引语是正确的'''但是你的开头引号都是* smart引号*,而不是ascii。你是否从其他应用程序中复制并粘贴了这些内容,这可能是你错误的原因。 –

回答

3

您需要使用适当的双引号,而不是符号,它不是ASCII。

+0

这是在评论中提到,但这些也被称为“聪明的报价”。几乎总是由网站的代码咬人造成的问题。 – Matt