本文實例講述了python列出目錄下指定文件與子目錄的方法。分享給大家供大家參考。具體實現方法如下:
1
2
3
4
5
6
|
# if you know the exact name: import os files = os.listdir( '/path/to/dir/' ) # if you want shell-style globbing: import glob files = glob.glob( '/path/to/dir/*.html' ) |
希望本文所述對大家的Python程序設計有所幫助。