gpt4 book ai didi

python - 关于换行符,我如何遵循 python PEP8,它有多重要?

转载 作者:太空狗 更新时间:2023-10-30 00:48:59 31 4
gpt4 key购买 nike

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

我将 gedit 与 pep8 一起使用和 pyflakes根据 python style guide 显示样式错误的插件.不知道要不要严格按照风格推荐。

但是,我有三个反复出现的样式缺陷,由 E501 指示:行太长(80 > 79 个字符)E502:括号之间的反斜杠是多余的E128/E127/...: continuation line under-indented for visual indent.屏幕截图如下。

我的两个问题是:

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

E501: enter image description here

E502: enter image description here

E127/128……: enter image description here

最佳答案

“我怎样才能在 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 已经在括号内,反斜杠是多余的。您是否尝试消除它?

关于python - 关于换行符,我如何遵循 python PEP8,它有多重要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34875169/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com