美文网首页
文件差分方法

文件差分方法

作者: K7_Lee | 来源:发表于2017-11-22 13:31 被阅读0次

#!/usr/bin/env python

# -*-coding:utf-8 -*-

importcsv

importsys

reload(sys)

sys.setdefaultencoding('utf8')

importos

importshutil

defgetFileList(path,company_name):

path  = path+r'\\'+company_name

f_list = os.listdir(path)

html_list = []

foriinf_list:

ifos.path.splitext(i)[1] =='.html':

html_list.append(i)

returnhtml_list

defReplace(template,filename,company_name):

lines =open(template+r'\\'+filename).readlines()

new_file = company_name+r'\\'+filename

fp =open(new_file,'w')

forlineinlines:

fp.write(line.replace('深圳市坤德物流有限公司',company_name))

fp.close()

return'success'

if__name__=='__main__':

company_Info = csv.reader(open('company_name.csv'))

company_List = []

forrowincompany_Info:

company_List.append(row)

printcompany_List

foriincompany_List:

company_name = i[0]

template = i[1]

shutil.copytree(template,company_name)

real_path = os.path.split(os.path.realpath(__file__))[0]

html_list = getFileList(real_path,company_name)

company_name =company_name.decode('gbk')

#html_list = getfileNmae('C:\\Users\\x_likangqi\\Documents\\nksebx\\nksebx.cn')

forfile_nameinhtml_list:

Replace(template,file_name,company_name)

相关文章

网友评论

      本文标题:文件差分方法

      本文链接:https://www.haomeiwen.com/subject/lbbnvxtx.html