Python OS库的文件操作使用

Python OS库的文件操作使用

循环遍历某个文件夹下的所有文件,包括子文件夹下的文件

root为根目录文件的路径,dirs为文件夹,files为文件的名称和后缀

for root, dirs, files in os.walk("D:\pythonProject1"):
    for file in files:
        print(os.path.join(root, file))

猜你喜欢

转载自blog.csdn.net/A4545156/article/details/132143683