两个文件内容同行合并操作

def hebing():       ##合并所需行
    file1path = 'Task_name.txt'
    file2path = 'Last_Run_Time.txt'

    file_1 = open(file1path,'r')
    file_2 = open(file2path,'r')


    list1 = []
    for line in file_1.readlines():
        ss = line.strip()
        list1.append(ss)
    file_1.close()

    list2 = []
    for line in file_2.readlines():
        ss = line.strip()
        list2.append(ss)
    file_2.close()

    file_new = open('hebing1.txt','w')
    for i in range(len(list1)):
       sline = list1[i] + '*' + list2[i]
       file_new.write(sline+'
')
    file_new.close()
善战者,求之于势,不责于人,故能择人而任势
原文地址:https://www.cnblogs.com/NGU-PX/p/11322294.html