- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
你应该如何分解一个很长的列表理解?
[something_that_is_pretty_long for something_that_is_pretty_long in somethings_that_are_pretty_long]
我还曾在某处看到人们不喜欢使用“\”来分行,但一直不明白为什么。这背后的原因是什么?
最佳答案
[x
for
x
in
(1,2,3)
]
工作正常,所以你可以随心所欲。我个人更喜欢
[something_that_is_pretty_long
for something_that_is_pretty_long
in somethings_that_are_pretty_long]
\
不受欢迎的原因是它出现在一行的 end 处,它要么不突出,要么需要额外的填充,当行长改变时必须固定:
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)
关于python - python中列表推导或生成器表达式的续行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5809059/
给定: e = 'a' + 'b' + 'c' + 'd' 如何将上面的内容写成两行? e = 'a' + 'b' + 'c' + 'd' 最佳答案 那条线是什么?您可以在下一行添加参数,没有
这个问题在这里已经有了答案: How to put a line comment for a multi-line command [duplicate] (4 个答案) 关闭 8 年前。 我的 s
我有一长行代码,我想将其拆分为多行。我用什么,语法是什么? 例如添加一串字符串: val text = "This " + "is " + "a " + "long " + "long " + "li
给定: e = 'a' + 'b' + 'c' + 'd' 上面两行怎么写? e = 'a' + 'b' + 'c' + 'd' 最佳答案 线是什么?您可以在下一行输入参数而没有任何问题: a
我有以下 SQL 脚本 (initDB.sql) CREATE TABLE FFShareHistorical ( ID int NOT NULL AUTO_INCREMENT,
我是一名优秀的程序员,十分优秀!