为什么Pylint说print('foo',end ='')语法无效?

时间:2016-09-20 16:06:03

标签: python pylint

这个非常简单的代码:

#!/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)

为什么?

1 个答案:

答案 0 :(得分:4)

运行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