Can't get past illogical line pep8 error
我已经试着解决这个问题有一段时间了,我就是不能让它通过佩普8。这是我的代码:
1。
1 2 3 4 5 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and sum(regex.count(char) for char in splitter) == 1 and regex.count('(') == 1 and regex.count(')') == 1): print('hi') |
2。
1 2 3 4 5 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and sum(regex.count(char) for char in splitter) == 1 and regex.count('(') == 1 and regex.count(')') == 1): print('hi') |
三。
1 2 3 4 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and regex.count('(') > 1): print('hi') |
我在3条if语句中的每一条上都得到以下PEP8错误:
1 | E125 continuation line does not distinguish itself from next logical line |
你知道怎么回事吗?行与第一个括号缩进,所以我真的没有线索。
1。
1 2 3 4 5 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and sum(regex.count(char) for char in splitter) == 1 and regex.count('(') == 1 and regex.count(')') == 1): print('hi') |
2。
1 2 3 4 5 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and sum(regex.count(char) for char in splitter) == 1 and regex.count('(') == 1 and regex.count(')') == 1): print('hi') |
三。
1 2 3 4 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and regex.count('(') > 1): print('hi') |
我正在使用Pycharm(这非常适合指出PEP8错误)进行编辑,它说这个版本可以:
1 2 3 4 5 | if (len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and sum(regex.count(char) for char in splitter) == 1 and regex.count('(') == 1 and regex.count(')') == 1): print('hi') |
我不是说我喜欢这个解决方案,但我认为在
1 2 3 4 5 | if(len(regex) > 2 and regex[0] == '(' and regex[-1] == ')' and sum(regex.count(char) for char in splitter) == 1 and regex.count('(') == 1 and regex.count(')') == 1): print('hi') |