我尝试遵守 pep8
指令,因此打破以下行:
config_data_dict['foo']['bar']['foobarfoo'] \
['barfoobar'] = something_else
但是,我在 ['foobarfoo']
部分之后收到以下警告
whitespace before '[' pep8(E211)
我应该如何像上面那样正确地断行(假设我不能在 =
附近断行)?
最佳答案
括号似乎有效:
(config_data_dict['foo']['bar']['foobarfoo']
['barfoobar']) = something_else
这似乎也是根据 PEP8 推荐的样式:
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.
关于python - 断线访问字典的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57148916/