for I in [] or [1,2,3] 这种用法你肯定没见过吧

1. [] or [1,2,3]

 for i in [] or [1,2,3]:
    print(i)

将会输出1,2,3

2.[1,2,3] or []

 for i in [1,2,3] or []
    print(i)

将会输出1,2,3

3.[1,2,3] and []

for i in [1,2,3] and []:
    print(i)

将会输出空值

4.[4,5,6] or [1,2,3]

for i in [4,5,6] or [1,2,3]:
print(i)

将会输出4,5,6

5.[4,5,6] and [1,2,3]

for i in [4,5,6] and [1,2,3]:
    print(i)

将会输出1,2,3

猜你喜欢

转载自blog.csdn.net/weixin_38246633/article/details/85706546
3 I