python

python入门-文件操作

文件操作

import os
# f= open("D:\\00filetest\\1.txt",encoding='utf-8')
# with open('./filefold/write.txt', 'a') as targetFile:
targetFile = open('./filefold/write.txt', 'a')
f = open("filefold/a.txt", encoding='utf-8')
content = f.read()
# print(content)
# 按行读取采集编号
collectId = open("filefold/collectids.txt", encoding='utf-8')

while True:
    eachCid = collectId.readline().strip('\n')
    if not eachCid:
        break
    s = content.replace('"XXXX"', "'"+eachCid+"'")
    #   targetFile.writelines(s + "\n")
    targetFile.write(s+"\n")

新的改变

你可能感兴趣的:(python,python,开发语言)