def try_unicode(string, errors='strict'):
    if isinstance(string, str):
        return string
assert isinstance(string, str), repr(string)
for enc in encoding_guess_list:
    pass
How to know the encoding of a file in Python?