catch UnicodeDecodeError
Andrew Berg
bahamutzero8825 at gmail.com
Wed Jul 25 07:34:53 EDT 2012
More information about the Python-list mailing list
Wed Jul 25 07:34:53 EDT 2012
- Previous message (by thread): catch UnicodeDecodeError
- Next message (by thread): catch UnicodeDecodeError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 7/25/2012 6:05 AM, jaroslav.dobrek at gmail.com wrote: > What I really want to do is use something like > > try: > # open file, read line, or do something else, I don't care > except UnicodeDecodeError: > sys.exit("Found a bad char in file " + file + " line " + str(line_number) > > Yet, no matter where I put this try-except, it doesn't work. > > How should I use try-except with UnicodeDecodeError? The same way you handle any other exception. The traceback will tell you the exact line that raised the exception. It helps us help you if you include the full traceback and give more detail than "it doesn't work". -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803
- Previous message (by thread): catch UnicodeDecodeError
- Next message (by thread): catch UnicodeDecodeError
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list