1 #coding=utf-8 2 import os 3 import time 4 while 1: 5 os.system(‘ls‘) 6 oldfilename=raw_input("input file‘s name which you want backup:") 7 if os.path.exists(oldfilename): 8 now=time.strftime(‘%Y%m%d%H%M‘,time.localtime()) 9 bakfilename=oldfilename+now 10 os.system(‘cp %s %s ‘%(oldfilename,bakfilename)) 11 print ‘-----done------‘ 12 exit(0) 13 else: 14 print ‘%s not existed!‘ %oldfilename
原文:http://www.cnblogs.com/puer633/p/6691242.html