在使用Visual Studio Code内部运行Python时出现语法错误。
在使用Visual Studio Code内部运行Python时出现语法错误。
我在我的电脑上保存了一个包含以下内容的Python文件:
types_of_people = 10 x = f"There are {types_of_people} types of people" binary = "binary" do_not = "don't" y = f"Those who know {binary} and those who {do_not}." print(x) print(y) print(f"i said: {x}") print(f"I also said: '{y}'") hilarious = False joke_evaluation = "Isn't that joke so funny?! {}" print(joke_evaluation.format(hilarious)) w = "This is the left side of ..." e = "a string with a right side." print(w + e)
当我用Visual Studio Code中的Python 3.7打开这个文件时,我得到以下错误:
/usr/local/opt/python/bin/python3.7 /Users/andree/Desktop/test.py File "", line 1 /usr/local/opt/python/bin/python3.7 /Users/andree/Desktop/test.py ^ SyntaxError: invalid syntax
在下面的屏幕截图中,你可以看到我用来运行文件的命令,以及我使用的Python扩展。
但是在我的终端中使用python3 test.py
运行文件是可以正常工作的。
有人知道在使用VS Code运行时出现的问题吗?