获取目录路径和文件路径
import os
for root, dirs, files in os.walk(".", topdown=False): # ‘.’为获取脚本所在路径下的同级文件及目录路径,‘..’则获取脚本所在路径上一级文件及目录路径
for name in files:
print(os.path.join(root, name))
for name in dirs:
print(os.path.join(root, name))
import os
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
print(os.path.join(root, name))
for name in dirs:
print(os.path.join(root, name))