PEP-8 分解 for 循环

问题描述 投票:0回答:2

我正在尝试找出一种方法来打破长 for 循环,使其 PEP-8 有效。 (我正在使用 flake8 vscode 扩展)。

这是代码:

for result_row in soup.find_all('div', {"class": "b2c-inner-data-wrapper"}):
    ..............

我得到的错误是:

line too long (88 > 79 characters)

我已经尝试过:

for result_row in soup.find_all('div',
{"class": "b2c-inner-data-wrapper"}):

但我明白:

continuation line under-indented for visual indent

正确的做法是什么? 谢谢。

python beautifulsoup pep8 flake8
2个回答
1
投票
result_rows = soup.find_all('div', {"class": "b2c-inner-data-wrapper"})
for result_row in result_rows:
    ..............

0
投票
for result_row in soup.find_all(
        'div',
        {"class": "b2c-inner-data-wrapper"}
):
© www.soinside.com 2019 - 2024. All rights reserved.