[英]Python Lambda function to check if a variable is NULL or empty or None
只是想了解 lambda function
問題:- 如果變量“txt”不是 null 或為空或無,則變量“sep”應返回“-”。 下面是我嘗試過的,但它充滿了語法錯誤
txt="askjdh"
sep=lambda x: '-' if txt
sep=lambda x: '-' if txt else ''
?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.