1、删除和重命名文件
import os import string def replace(file, search_for, replace_with): # replace strings in a text file back = os.path.splitext(file)[0] + ".bak" (1) temp = os.path.splitext(file)[0] + ".tmp" try: # remove old temp file, if any os.remove(temp) (2) except os.error[......]