import os
output_file = open(filename, 'w')
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
f = print(os.path.join(root, name))
output_file.write(f)
for name in dirs:
print(os.path.join(root, name))
output_file.close()
也可以使用listdir()方法
file = open(filename, 'w')
for f in os.listdir(dirName):
f = os.path.join(dirName, f)
file.write(f)
file.close()
你可以试试这样的。你知道吗
也可以使用
listdir()
方法相关问题 更多 >
编程相关推荐