7

我正在使用 python 3.5.1 编写,我是一名编程新手。

我将 gedit 与pep8pyflakes插件一起使用,根据python 样式指南显示样式错误。我不知道是否要按照风格推荐信。

然而,我有三个反复出现的风格缺陷,由E501: line too long (80 > 79 characters)E502: the backslash is redundant between brackets表示E128/E127/...: continuation line under-indented for visual indent。截图如下。

我的两个问题是:

  1. 如何在 python 中充分换行以避免E501随后的样式错误E502E127/128
  2. 遵循风格指南 pep8 是否有帮助,尤其是考虑到出版?高级python程序员怎么说?

E501: 在此处输入图像描述

E502: 在此处输入图像描述

E127/128...: 在此处输入图像描述

4

1 回答 1

9

“为了避免 E501 和随后的样式错误 E502 和 E127/128,我怎样才能充分地在 python 中进行换行?”

progress = Utils.ProgressMeter('Source strings separated by white '
    'space are automatically concatenated by the '
    'interpreter and parenthesis are the natural syntax '
    'for line continuation. Remember to use trailing '
    'spaces.')

由于错误 E502 已经在括号内,因此反斜杠是多余的。你试过消除它吗?

于 2016-01-19T11:21:34.723 回答