如何用python从文中获取文件名再用正则表达式批量修改文件名,python批量处理文件名称

首页 > 时尚 > 作者:YD1662025-06-07 10:14:21

如何用python从文中获取文件名再用正则表达式批量修改文件名,python批量处理文件名称(1)

import osx = 1while x < 101:if x < 10:file_name = "0"+str(x) + ".txt" #10一下则前面补零file = open(file_name)else:file_name = str(x) + ".txt"file = open(file_name)line = file.readline()file.close()os.rename(file_name,line) #重命名x = x + 1

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.