环境python3.6 合并前第一个文件和第二个文件 代码 file1 = open("my.txt","r")file2 = open("ids.txt","r") file1_lists =file1.readlines()file2_lists =file2.readlines() file3_list = []file4_list = []for i in file1_lists: temp_li
环境python3.6
合并前第一个文件和第二个文件
代码
file1 = open("my.txt","r") file2 = open("ids.txt","r") file1_lists =file1.readlines() file2_lists =file2.readlines() file3_list = [] file4_list = [] for i in file1_lists: temp_list = i.split() file3_list.append(str(temp_list[0])) # print(len(file3_list)) for i in file2_lists: temp_list = i.split() file4_list.append(str(temp_list[0])) # print(len(file4_list)) main_file = [] for i in range(len(file3_list)): s="" s = "".join([file3_list[i],file4_list[i]]) s+="\n" main_file.append(s) file3 = open("three.txt","w") file3.writelines(main_file)
合并后的文件
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。