如何迭代給定目錄中的文件?我需要遍歷所有.asm在給定目錄中的文件并對它們執行一些操作。如何有效地做到這一點?
3 回答

哈士奇WWW
TA貢獻1799條經驗 獲得超6個贊
import osfor subdir, dirs, files in os.walk(rootdir): for file in files: #print os.path.join(subdir, file) filepath = subdir + os.sep + file if filepath.endswith(".asm"): print (filepath)
添加回答
舉報
0/150
提交
取消