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

标签 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)

为什么?

最佳答案

我在运行 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/

相关文章:

Python - 在使用正则表达式查找句点(句号或 .)时,我应该使用字符串前缀 r 吗?

Python:无法启动新线程。我可以错开或延迟一些线程吗?

git - 仅从 'git diff' 获取静态代码分析器消息?

makefile - 如何编写一个makefile来运行pylint?

python - sklearn Python 和逻辑回归

python - map/filter/reduce 函数序列的干净代码

python - 如何将 Pylint 与 Geany 集成,以便我可以将 Geany 用作 python IDE?

python - 停止 pylint 提示 flask route 未使用的函数名称的惯用方法?

python - PyLint 错误地表示对象缺少某些属性

python - 使用带有 try-except block 的 python "with"语句