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