[英]Python Lambda function to check if a variable is NULL or empty or None
Just trying to understand lambda function只是想了解 lambda function
problem:- variable "sep" should return "-" if variable "txt" is not null or empty or none.问题:- 如果变量“txt”不是 null 或为空或无,则变量“sep”应返回“-”。 Below is what I tried, but it's full of syntax error下面是我尝试过的,但它充满了语法错误
txt="askjdh"
sep=lambda x: '-' if txt
sep=lambda x: '-' if txt else ''
? sep=lambda x: '-' if txt else ''
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.