1

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()
1
  • Welcome to Stack Overflow. Also consider looking at these threads. Commented Nov 11, 2021 at 5:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.