返回不同值的小技巧

it2025-01-14  20

>>> hobbies = ['software'] >>> ('notchecked', 'checked')['software' in hobbies] 'checked' >>> 'checked' if 'software' in hobbies else 'notchecked' 'checked' >>> hobbies = ['xxx'] >>> 'checked' if 'software' in hobbies else 'notchecked' 'notchecked' >>>

 

转载于:https://www.cnblogs.com/tuzkee/p/6386989.html

最新回复(0)