Skip to content

Instantly share code, notes, and snippets.

@Answeror
Created October 9, 2012 01:59
Show Gist options
  • Select an option

  • Save Answeror/3856139 to your computer and use it in GitHub Desktop.

Select an option

Save Answeror/3856139 to your computer and use it in GitHub Desktop.
Python3 try decode.
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