materials
materials copied to clipboard
Add example using 'with' statement and urlopen
This pull request adds a beginner-friendly Python example to demonstrate the use of the with statement with urllib.request.urlopen() for safely opening and reading a URL. This addresses Issue #423.
The example is located in:
context-managers/urlopen-example/with_urlopen_example.py
It includes a simple script that fetches content from https://www.python.org and prints the first 200 bytes. The code also contains helpful comments for learners.