import os current_dir="D:\百度网盘\Download\F-罚丨Z\\" #需要改 file_iterator = os.scandir(current_dir) for file_info in file_iterator: houzhui = file_info.name.split(".") if len(houzhui)>=2: if houzhui[1] == "pdf": name = houzhui[0]+".mp4" name0 = current_dir+file_info.name name1 = current_dir+name os.rename(name0, name1)
标签:info,name,后缀,houzhui,current,MP4,file,PDF,dir From: https://www.cnblogs.com/qj696/p/17754021.html