<p>我的机器上保存了一个包含以下内容的python文件:</p>
<pre><code>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)
</code></pre>
<p>当我从Visual Studio代码中使用Python 3.7打开此文件时,出现以下错误:</p>
<pre><code>/usr/local/opt/python/bin/python3.7 /Users/andree/Desktop/test.py
File "<stdin>", line 1
/usr/local/opt/python/bin/python3.7 /Users/andree/Desktop/test.py
^
SyntaxError: invalid syntax
</code></pre>
<p>在下面的屏幕截图中,您可以看到我用来运行文件的命令,以及我使用的python扩展名</p>
<p><a href="https://i.stack.imgur.com/zc4DO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/zc4DO.jpg" alt="run python file from within Visual Studio Code"/></a></p>
<p>但是在我的终端中使用<code>python3 test.py</code>运行该文件就可以了</p>
<p>有人知道在VS代码中运行它时会出现什么问题吗</p>