发布网友 发布时间:2022-05-03 09:12
共1个回答
热心网友 时间:2022-05-10 07:00
import os
name = {}
with open("dict.txt","r") as A:
for eachline in A:
eachline = eachline.rstrip()
save = eachline.split(',')
name[save[0]] = save[1]
dir = './'
files = os.listdir(dir)
for file in files:
filename = os.path.splitext(file)[0]
sufix = os.path.splitext(file)[1]
if(sufix == '.mp3' and filename in name):
src1 = os.path.join(dir,file)
print name[filename]+sufix
src2 = os.path.join(dir,name[filename]+sufix)
os.rename(src1,src2)
这样吗?