with urllib.request.urlopen("http://www.python.org") as url:
s = url.read()
#I'm guessing this would output the html source code?
@Sergio: exactly! And through the indentation you see where your file is still opened.
Hello @eumiro, I have an error of "IndentationError: expected an indented block" when I type s = url.read(), may I ask how can I solve it please? x
Hi Eumiro, using the 'with' statement in Python I'm guessing it closes the connection automatically once it's done using it? Similar to a use statement in C#?
This works in Python 2.x.