python lambda if语句
时间: 2023-08-21 13:10:13 浏览: 111
在匿名函数(lambda)中,不能使用if语句。匿名函数的主体是一个表达式,而不是一个代码块,只能在lambda表达式中封装有限的逻辑进去。因此,无法在匿名函数中使用if语句来进行条件判断。\[1\]
#### 引用[.reference_title]
- *1* [Python学习-lambda表达式](https://blog.csdn.net/weixin_39694016/article/details/110331823)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [Python中lambda匿名函数的使用](https://blog.csdn.net/weixin_44695969/article/details/93639723)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文