gpt4 book ai didi

python - PEP8 : continuation line over-indented for visual indent

转载 作者:IT老高 更新时间:2023-10-28 20:53:43 34 4
gpt4 key购买 nike

我有这行代码,在测试 pep8 错误时我得到:线太长。因此,为了尝试解决此问题,我使用了 slash('\') 但随后我将延续行过度缩进以进行视觉缩进。我该怎么做才能解决这个问题?

enter image description here

我尝试过的事情:

if first_index < 0 or second_index > \
self._number_of_plates - 1:
raise ValueError

continuation line over-indented for visual indent

if first_index < 0 \
or second_index > \
self._number_of_plates - 1:
raise ValueError

continuation line over-indented for visual indent

if first_index < 0 or \
second_index > self._number_of_plates - 1:
raise ValueError

continuation line over-indented for visual indent

if first_index \
< 0 or second_index \
> self._number_of_plates - 1:
raise ValueError

continuation line over-indented for visual indent

最佳答案

行扩展反斜杠的问题是尾随空格会破坏您的代码。这是一种流行的修复方法,并且符合 PEP8:

if (first_index < 0 or
second_index > self._number_of_plates - 1):

关于python - PEP8 : continuation line over-indented for visual indent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21947121/

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