关于换行,我如何遵循PythonPEP8,它有多重要?

2024-04-26 14:01:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我是用python 3.5.1编写的,我是一个编程新手。

我使用gedit和一个pep8pyflakes插件,根据python style guide显示样式错误。我不知道信中是否有文体推荐。

但是,我有三个重复出现的样式缺陷,分别是E501: line too long (80 > 79 characters)E502: the backslash is redundant between bracketsE128/E127/...: continuation line under-indented for visual indent。下面是截图。

我的两个问题是:

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

E501标准: enter image description here

E502标准: enter image description here

E127/128…: enter image description here


Tags: 插件标准style编程错误line样式pyflakes
1条回答
网友
1楼 · 发布于 2024-04-26 14:01:27

“如何在python中充分换行以避免E501和随后的样式错误E502和E127/128?”

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已经在括号内,所以反斜杠是多余的。你试过消除它吗?

相关问题 更多 >