📜  列表理解 if-else - Python 代码示例

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

代码示例2
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]