Python regular processing of local txt files

recently, I was learning about crawlers, and then I used get to connect to the web page, and then I asked a lot of questions. I said one by one, when I get, I added the following information

params = header
header = {user-agent: xxxx}

the resulting text basically adds my user-agent information at the end of each chapter, as shown in the figure, which should be caused by the script of the page. No, ignore

clipboard.png

clipboard.png

for in

(^http.*$com) httpcompython Orz


re.sub the third parameter is of the wrong type and should be changed to

old_content = open('1.txt', 'rb').read()
new_content = re.sub(br'http://[^\s]+', b'', old_content)
Menu