当前位置: 首页 > 后端技术 > Python

[python]IfnotPython中的用法

时间:2023-03-26 13:01:26 Python

python中判断语句None,False,空字符串"",0,空列表[],空字典{},空元组()等同于FalsenotNone==notFalse==not''==not0==not[]==not{}==not()需要注意的是'0'的判断返回truedeftest(val):ifnotval:print'not'else:print'yes'test(0)test(None)test('0')ifnot0:print1111返回notnotyes1111