python 生成excel自动重命名_用Python重命名和保存Excel文件

检查^{}和^{}模块以列出文件夹内容(walk,listdir)并使用路径名(abspath,basename等)

另外,^{}还有一些有趣的复制功能。签出copyfile,并根据从excel文件中读取的数据指定dst参数。在

您可能需要一些类似这样的高级代码:for subfolder_name in os.listdir(MAIN_FOLDER):

# exercise left to reader: filter out non-folders

subfolder_path = os.path.join(MAIN_FOLDER, subfolder_name)

for excel_file_name in os.listdir(os.path.join(MAIN_FOLDER, subfolder_name)):

# exercise left to reader: filter out non-excel-files

excel_file_path = os.path.join(subfolder_path, excel_file_name)

new_excel_file_name = extract_filename_from_excel_file(excel_file_path)

new_excel_file_path = os.path.join(NEW_MAIN_FOLDER, subfolder_name,

new_excel_file_name)

shutil.copyfile(excel_file_path, new_excel_file_path)

您必须使用我提到的站点中的xlrd模块自己提供extract_filename_from_excel_file。在

    原文作者:盐于律己鸭
    原文地址: https://blog.csdn.net/weixin_34928052/article/details/112942776
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞