语法无效(<string>,第 4 行)(语法错误)
invalid syntax (<string>, line 4) (syntax-error)
根据 flake8、pylint,我的语法无效,但代码有效。
该代码有什么问题?
我做了很多 Google 搜索,但找不到任何东西。
#!/usr/bin/env python
with open("test.py", "a") as output:
# E: 4, 0: invalid syntax (<string>, line 4) (syntax-error)
print("hello world", file=output)
你 运行 Python 是什么版本?我不确定它到底是什么时候实现的,但我认为 Python 的早期版本没有 file=output 函数的 print() 参数,所以你的解释器可能只需要一个 string
根据 flake8、pylint,我的语法无效,但代码有效。 该代码有什么问题?
我做了很多 Google 搜索,但找不到任何东西。
#!/usr/bin/env python
with open("test.py", "a") as output:
# E: 4, 0: invalid syntax (<string>, line 4) (syntax-error)
print("hello world", file=output)
你 运行 Python 是什么版本?我不确定它到底是什么时候实现的,但我认为 Python 的早期版本没有 file=output 函数的 print() 参数,所以你的解释器可能只需要一个 string