Skip to content

Instantly share code, notes, and snippets.

@hgz6536
Created April 21, 2017 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgz6536/dc312bfad4a3fc4cb3de7b44ec4747d9 to your computer and use it in GitHub Desktop.
Save hgz6536/dc312bfad4a3fc4cb3de7b44ec4747d9 to your computer and use it in GitHub Desktop.
遍历目录的所有文件
#!/usr/bin/python
def print_directory_contents(sPath):
import os
for sChild in os.listdir(sPath):
#print sChild
sChildPath = os.path.join(sPath,sChild)
if os.path.isdir(sChildPath):
print_directory_contents(sChildPath)
else:
print sChildPath
print_directory_contents("/home")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment