在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ PEP8中的E127如何理解?

PEP8中的E127如何理解?

在使用sublime編輯時(shí)彈出的PEP8中的E127:continuation line over-indented for visual indent如何理解?

回答
編輯回答
乖乖噠

代碼風(fēng)格問題.
PEP8 中指出:

Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent [7]. When using a hanging indent the following should be considered; there should be no arguments on the first line and further indentation should be used to clearly distinguish itself as a continuation line.

也就是說在括號內(nèi)的參數(shù)很多的時(shí)候, 為了滿足每一行的字符不超過79個(gè)字符, 需要將參數(shù)換行編寫, 這個(gè)時(shí)候換行的參數(shù)應(yīng)該與上一行的括號對齊.
或者將所有參數(shù)換行編寫, 此時(shí)第一行不能有參數(shù), 即第一行的最后一個(gè)字符一定要是(, 換行后需要有一個(gè)縮進(jìn). 類似的規(guī)則也用在[], {}上.
例子:

# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
                         var_three, var_four)

# Hanging indents should add a level.
foo = long_function_name(
    var_one, var_two,
    var_three, var_four)
2017年6月28日 01:29