如何用python從文中獲取文件名再用正則表達式批量修改文件名?
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