python怎么把文件加到file中
发布网友
发布时间:2022-09-14 20:13
我来回答
共1个回答
热心网友
时间:2024-04-03 14:48
执行的python脚本:
1234567891011121314151617
#!/usr/local/python # coding=UTF-8 import os file = open( "test.html", "r" ) fileadd = open("test.txt","r") content = file.read() contentadd = fileadd.read() file.close() fileadd.close() pos = content.find( "</table>" ) if pos != -1: content = content[:pos] + contentadd + content[pos:] file = open( "test.html", "w" ) file.write( content ) file.close() print "OK"