alphabet
uses various methods to recognize text.
The easiest way to install the package is via pip
:
$ pip install alphabet
from alphabet import alphabet
alphabet('%!').identify()
> 'PostScript document text'
alphabet('import os').identify()
> 'Python'
alphabet('<div>foobar</div>').identify()
> 'XML'
alphabet('Привет').identify()
> 'ru'