import os
file_path = r'C:\Users\rxdrd\Desktop\file_upload\fdm-hql'
file_names = []
for root, dirs, files in os.walk(file_path, topdown=False):
for name in files:
file_names.append(os.path.join(root, name))
# print(root)
# # print(dirs)
# for name in dirs:
# print(name)
#
# print(os.path.join(root, name))
file_list = file_path.split('\\')
index = file_list.index('file_upload')
print(file_list[index+1:])
print(file_names)
file = []
for fil in file_names:
tmp_list = fil.split('\\')
index = tmp_list.index('fdm-hql')
file_name = '/'.join(tmp_list[index:])
print(file_name)
获取文件名
最新推荐文章于 2023-09-24 16:17:57 发布