Created
October 9, 2012 01:59
-
-
Save Answeror/3856139 to your computer and use it in GitHub Desktop.
Python3 try decode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def decode(bs, encodings=['utf-8', 'cp936', 'gbk', 'gb18030', 'big5', 'latin1']): | |
| for en in encodings: | |
| try: | |
| return bs.decode(en) | |
| except: | |
| pass | |
| raise RuntimeError('Decoding failed.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment