In the use of other people's Code, to not retain the file header copyright information, need to delete, time-consuming and laborious,
Write a script that simply clears all the files in the directory under the header copyright information.
#-*-Coding:utf8-*-"Remove the copyright in the header of the Java file and other comments above the package" ' Import OS import sys def delheader (filepath): if Os.path . Exists (filepath): File = open (filepath) lines = File.readlines () Beforetag = Truewriter = open (filepath, ' W ') for line I N lines:if ' package ' in Line:beforetag = falseif Beforetag = = False:writer.write (line) if __name__ = = ' __main__ ': Path= ' f:\\space\\xxx\\src ' list = Os.walk (path, True) for dir in list:files = dir[2] for file in Files:if '. Java ' in Fil E:filepath = Os.path.join (dir[0], file) print filepath Delheader (filepath) print ' Complete!!!!!!!!!!!!!!! '