文件内容拼接
将两个文件内容进行拼接
fid_a = open('a.txt') fid_b = open('b.txt') fid_c = open('c.txt','w') lines_a = fid_a.readlines() lines_b = fid_b.readlines() lines_c = [] for i in range(0,len(lines_b)): lines_a[i]= lines_a[i].strip('\n\r') lines_c.append(lines_a[i]+lines_b[i]) fid_c.writelines(lines_c[i])
cat a.txt b.txt >c.txt似乎也可以
但是没有strip操作,不够灵活