一、

>>> test1 = ["ccc","ddd","mmm"]
>>> if test1:
    for i in test1:
        print(i)
else:
    print("empty list")

    
ccc
ddd
mmm
>>> test1 = []
>>> if test1:
    for i in test1:
        print(i)
else:
    print("empty list")

    
empty list

 

二、

>>> test1 = ["ccc","eee","kkk"]
>>> lenlist=len(test1)
>>> if lenlist != 0:
    for i in test1:
        print(i)
else:
    print("empty list")

    
ccc
eee
kkk
>>> test1 = []
>>> lenlist=len(test1)
>>> if lenlist != 0:
    for i in test1:
        print(i)
else:
    print("empty list")

    
empty list

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-01-24
  • 2021-10-07
  • 2022-12-23
相关资源
相似解决方案