pyhton中简单if else语句

a = [1,1,1]
b = a if len(a) != 0 else "123"
print(b)

c=[]
d = c if len(c) != 0 else "123"
print(d)

输出结果为:

[1,2,3]
[1,2,3]

猜你喜欢

转载自blog.csdn.net/hanshihao1336295654/article/details/80454589