这段非常简单的代码:
#!/usr/bin/python3
print('foo', end='')
让 Pylint 不开心(在 Python2 和 Python3 上):
pylint ./pylint.py
No config file found, using default configuration
************* Module pylint
E: 2, 0: invalid syntax (syntax-error)
为什么?
最佳答案
我在运行 pylint 时遇到了这个错误。但是我的pylint只支持python2。所以它出错了:
$ pylint foo.py
No config file found, using default configuration
************* Module foo
E: 2, 0: invalid syntax (syntax-error)
所以我做了 pip3 install pylint
。
然后一切正常(或者至少它克服了语法错误):
$ python3 -m pylint foo.py | head
No config file found, using default configuration
************* Module foo
C: 1, 0: Black listed name "foo" (blacklisted-name)
C: 1, 0: Missing module docstring (missing-docstring)
.....
有关在一个系统中用于 python2 和 3 的 pylint 的更多信息,请参见此处:https://askubuntu.com/questions/340940/installing-pylint-for-python3-on-ubuntu
关于python - 为什么 Pylint 说 print ('foo' , end ='' ) 是无效语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39598921/