📜  如何使用条件格式的列表压缩 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:34.147000             🧑  作者: Mango

代码示例1
# You can totally do that. It's just an ordering issue:

[unicode(x.strip()) if x is not None else '' for x in row]
# In general,

[f(x) if condition else g(x) for x in sequence]
# And, for list comprehensions with if conditions only,

[f(x) for x in sequence if condition]