[Solved] Why there is double\r\n instead of \r\n in the codes


what is the mean of picture=b''

This is setting the picture variable to an empty byte array, which will be added to later.

what is pos for?

In pos = picture.find(b"\r\n\r\n"), the code is looking for the end of the HTTP header that comes before the picture data.

What is [pos+4:] in picture=picture[pos+4:] for?

The comment above it explains it, it “Skips past the header” to just get the picture data.

How can I view the image?

In these two lines,

fhand = open("stuff.jpg", "wb")
fhand.write(picture)

the picture is saved to a file titled stuff.jpg, you should be able to double click in a file manager to open it.

7

solved Why there is double\r\n instead of \r\n in the codes