import os file_names = os.listdir(‘D:\\mobilefile\\_hd‘) for file_name in file_names : print(file_name) print(file_name[:-1]) os.renames("D:\\mobilefile\\_hd\\"+file_name,"D:\\mobilefile\\_hd\\"+file_name[:-1])
原文:https://www.cnblogs.com/xiaodebing/p/9321622.html