1. 程式人生 > >for I in [] or [1,2,3] 這種用法你肯定沒見過吧

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