A web page file has multiple encoding methods at the same time, such as UTF-8 and Unicode escape. When I read and delete the specified string, I write it again. If I only use Unicode escape encoding, there will be people who cannot write to the file. \ R \ n this is not what I need. What should I do?
write_name = 'advisor_appendices111.htm'
file_name = 'advisor_appendices.htm'
f = open(file_name, "r", encoding=code)
f.readline()
print(f)
for line in f:
line = line.replace('../../%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/documentation/', '')
fpw = open(write_name, "a+", encoding=code)
fpw.write(line + '\n')
fpw.close()