循环方法:

import os
def allfile(basepath):
    for item in os.path.listdir(basepath):
        path = os.path.join(basepath, item)
        if os.path.isfile(path):
            print item
        else:
            allfile(path)

不循环方法:

import os

for dirpath, dirnames, filenames in os.walk(basepath):
   
    for filename in filenames:
        print(filename)

 

相关文章:

  • 2021-12-23
  • 2021-08-28
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2022-03-01
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2021-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-08-24
相关资源
相似解决方案