모든 파일의 첫 줄에 # - * - encoding: gbk - * -

1195 단어
# -*- encoding:utf-8 -*-

#==================================
#  JC 
#==================================

import os

if __name__ == '__main__' :
    #   # -*- encoding:gbk -*-
    folder_path = os.path.dirname(__file__)
    files = os.listdir(folder_path)
    for file_name in files:
        if file_name.startswith( 'JC' ):
            file_path = os.path.join(folder_path, file_name)
            if os.path.exists(file_path):
                lines = ['# -*- encoding:gbk -*-

' ] # read file_object = open(file_path) read_lines = file_object.readlines() if read_lines: if read_lines[0] == '# -*- encoding:gbk -*-
' : continue else: continue for line in read_lines: lines.append(line) # write file_object = open(file_path, 'w' ) for line in lines: file_object.write(line) file_object.close()

좋은 웹페이지 즐겨찾기