How can I catch a bug in python 3? I googled a lot, but none of the answers seem to work. The open.txt file does not exist, so it should print e.errno.
Here is what I tried now:
This is in my specific function.
try: with open(file, 'r') as file: file = file.read() return file.encode('UTF-8') except OSError as e: print(e.errno)
However, I don't print anything when I get this error
FileNotFoundError: [Errno 2] No such file or directory: 'test.txt'
Thomas w
source share