[x for x in (1,2,3)]
效果很好,因此您几乎可以随心所欲。我个人更喜欢
不能被很好理解的原因是它出现在一行的 末尾 ,要么不突出,要么需要额外的填充,当行长改变时必须固定它:[something_that_is_pretty_long for something_that_is_pretty_long in somethings_that_are_pretty_long]
x = very_long_term + even_longer_term_than_the_previous + a_third_term
在这种情况下,请使用括号:
x = (very_long_term + even_longer_term_than_the_previous + a_third_term)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)