current position:Home>How to deal with the problem of general code framework

How to deal with the problem of general code framework

2022-02-03 00:52:25 CSDN Q & A

img


The phenomenon and background of the problem
I won't send the code Prompt text error The following code snippet must use a code control :
Problem related code ,

ide Code input completed enter No return news Operation results and error reporting contents

img

img

Replace ide function Report errors Under the guidance My solution ideas and tried methods

What I want to achieve

img




Refer to the answer 1:
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'}

Yours expect And the back of the return No indent alignment , This is the code inside the function , To align , It is not recommended to copy and paste directly , And yours headers The Chinese character inside should be replaced by your browser F12 after network Of a packet useragent




Refer to the answer 2:



Refer to the answer 3:

This is a format problem ,python Is a language that takes indentation as the format .

img

take try Start with the second sentence below , Until the first return To indent backward 4 A space ( Or a tab)
except To indent backward 4 A space , Below return To indent backward 8 A space , Then try it .




Refer to the answer 4:



Refer to the answer 5:

And yours is not called a frame , And it's not universal , As long as there is a little anti climbing means , You can't run this ( What comes out is not what you want , yes 404 Of HTML Information ), go expect over there




Refer to the answer 6:



Refer to the answer 7:

img

Indent of these positions




Refer to the answer 8:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030052229847.html

Random recommended