在VSCode写了一个很简单的程序:
str1 = 'Python is good'
print(str1.replace('Python', 'python'))
点击在终端运行时报错:
File “”, line 1
& C:Python challenge/test.py"
^
SyntaxError: invalid syntax
并非语法问题,而是因为在Python解释器的命令行下运行了程序:
>>> & C:/Python challenge/test.py"
应该在Windows的CMD下运行才对,所以先退出Python解释器:
>>> ^Z
在点击在终端运行就OK了:
PS C:Python challenge/test.py"
python is good