100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python 生成excel自动重命名_用Python重命名和保存Excel文件

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

时间:2021-12-14 11:34:01

相关推荐

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。在

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。