1 #!/usr/bin/env python3
 2 import os
 3 def bbb(dir_str):
 4     filepaths=[]
 5     abspath = os.path.abspath(dir_str)
 6     for x in os.listdir(abspath):
 7         filepath = os.path.join(abspath,x)
 8         if os.path.isdir(filepath):
 9             bbb(filepath)
10         else:
11             print(filepath)
12             filepaths.append(filepath)
13     return filepaths
14 
15 a=bbb('/home/momo/myfile/mydev/python')
16 print('len',len(a))

 

以上代码中有个问题待解决,在11行输出的文件名并未在12行中全部写入list中,需要查一下问题出在哪

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-09-01
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2021-08-10
相关资源
相似解决方案