Python 在txt文本指定行 添加字符串
file = open("*.txt",'r')
content = file.read()
file.close()
pos = content.find( "2.4G MAC address" )
if pos != -1:
content = content[:pos] + "\n" +"=========================================================================" + "\n"+"*****************" + "\n" + "**** P A S S ****"+"\n"+"*****************"+"\n" + content[pos:]
file = open( "*.txt", "w" )
file.write( content )
file.close()

浙公网安备 33010602011771号