Help on this please; Is a second urlopen needed, in the scenario I describe?
import urllib.request # Given you open a url resp = urllib.request.urlopen('http://httpbin.org/xml') # Then execute a read stuff = resp.read() # You can print the result print(stuff) # For this post pretend you see the result, it works. # Then if you read again stuff2 = resp.read() # You find that nothing results print(stuff2) '' # If you do the open again, then you can read again and # do get the results resp = urllib.request.urlopen('http://httpbin.org/xml') stuff2 = resp.read() # I see the resp object has a seek function(?). But if that can be used # to reset a pointer, instead of executing a urlopen again, I have not # figured it out. # If there is no real world reason to do a second read this way, then it # is just an academic question. I am a Python newbie.
buran write Apr-19-2021, 05:09 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.