zoukankan      html  css  js  c++  java
  • code

    1. import os  
    2.   
    3. def scanfile(path):  
    4.     filelist = os.listdir(path)  
    5.     allfile = []  
    6.     for filename in filelist:  
    7.         filepath = os.path.join(path,filename)  
    8.         if os.path.isdir(filepath):  
    9.             scanfile(filepath)  
    10.         print filepath   
    11. allfile = scanfile('C:/studyPy')  
    1. for path,d,filelist in os.walk("C:/studyPy"):  
    2.     for filename in filelist:  
    3.         os.path.join(path,filename)  
    4. import os    # Import the OS module
      arr = []
      if not os.path.exists('testdir'): # Check to see if it exists
      os.makedirs('testdir') # Create the directory
      print ('1000')
      else:
      for path, d, filelist in os.walk("testdir"):

      for filename in filelist:
      print (os.path.join(path, filename))



      def scanfile(path,arr):
      filelist = os.listdir(path)
      allfile = []
      for filename in filelist:
      filepath = os.path.join(path,filename)
      if os.path.isdir(filepath):
      scanfile(filepath)
      # print (filepath)
      arr.append(filepath)

      allfile = scanfile('testdir',arr)


      for file in arr:
      print("current filepath is : %s"%(file))
  • 相关阅读:
    第六次作业
    第五次作业
    第四次作业
    第三次作业
    第二次作业 计科一班程晨
    第一次作业 计科一班程晨
    第七次作业
    第五次作业
    第四次作业
    第三次作业
  • 原文地址:https://www.cnblogs.com/wcLT/p/6429596.html
Copyright © 2011-2022 走看看