print(1 + 1 > 3 and "1" or "2")
python中空字符""值是False,因此才有了True and "" or "Water"结果是Water。刚入python,恰巧正在一本书里看到。相互交流。
print(1 if 1+1>1 else 2)
三元表达式
最新推荐文章于 2024-09-07 20:08:36 发布
print(1 + 1 > 3 and "1" or "2")
python中空字符""值是False,因此才有了True and "" or "Water"结果是Water。刚入python,恰巧正在一本书里看到。相互交流。
print(1 if 1+1>1 else 2)