Created
April 21, 2017 10:30
-
-
Save hgz6536/dc312bfad4a3fc4cb3de7b44ec4747d9 to your computer and use it in GitHub Desktop.
遍历目录的所有文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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