【发布时间】:2020-11-26 08:01:50
【问题描述】:
print("Hi!")
name = input("what's your name? ")
print("It's nice to meet you,", name)
answer = input("Are you enjoying the course? ")
if answer =="Yes":
print("That's good to hear!")
else:
print("Oh no! That makes me sad!")
上面是代码,但下面总是出现这种语法错误
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> & C:/Users/gbemi/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/gbemi/Desktop/exercise files/chap01/01_03.py"
File "<stdin>", line 1
& C:/Users/gbemi/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/gbemi/Desktop/exercise files/chap01/01_03.py"
^
SyntaxError: invalid syntax
>>>
我已经去文件首选项设置检查路径,它是正确的。请问有什么问题,我是新手程序员。
【问题讨论】:
-
您需要缩进打印语句。在您的错误部分,您已经在 Python 命令行中。输入
quit(),然后运行命令C:/Users/gbemi/AppData/Local/Programs/Python/Python38-32/python.exe "c:/Users/gbemi/Desktop/exercise files/chap01/01_03.py"
标签: python-3.x input visual-studio-code terminal notepad