with open("条款.txt","r") as file:
content = file.read()
count = len(open(r"条款.txt",'r').readlines())
print(count)
email_address = input("请输入供应商邮箱:")
1#(str = abcd@def.com)
keyword="卖方: "
post = content.find(keyword)
if post != -1:
content = content[:post+len(keyword)]+email_address+content[post+len(keyword):]
2# ( content = content[:post+len(keyword)]+str+content[post+len(keyword):])
file1 = open(r"条款2.txt",'w')
file1.write(content)
如果你是要追加到最后,那么把w改为a+
如果你是要插入任意位置,那只能把文件里的数据先读取出来,插入,再重新写回去
文件在硬盘里是连续存储的,磁带你见过吧,你胡乱往里面写东西会覆盖掉原来的数据
指针