[Python] python搜索指定目录的代码演示 →→→→→进入此内容的聊天室

来自 , 2020-04-03, 写在 Python, 查看 130 次.
URL http://www.code666.cn/view/e6051b3b
  1. #------------------------------------------------------------------------------
  2. #           Name: search_directory.py
  3. #         Author: Kevin Harris
  4. #  Last Modified: 02/13/04
  5. #    Description: This Python script demonstrates how to use os.walk()
  6. #                 to walk through a directory hierarchy and list everything
  7. #                 found.
  8. #------------------------------------------------------------------------------
  9.  
  10. import os
  11.  
  12. for root, dirs, files in os.walk( os.curdir ):
  13.                
  14.         print( "root = " + root )
  15.  
  16.         for file in files:
  17.                 print( "file = " + file )
  18.  
  19.         for dir in dirs:
  20.                 print( "dir = " + dir )
  21.  
  22.         print( "\n" )
  23.  
  24. input( '\n\nPress Enter to exit...' )
  25.  
  26. #//python/8096

回复 "python搜索指定目录的代码演示"

这儿你可以回复上面这条便签

captcha