str_parse.py

mail@pastecode.io avatar
unknown
python
2 years ago
331 B
25
Indexable
Never
import unicodedata
u = input('Please enter string data:\n')

for i, c in enumerate(u):
    try:
        print(str(i)+'.', c, ord(c), '0x'+c.encode('utf-8').hex(),
                '%04x' % ord(c), format(ord(c), 'b'),
                unicodedata.category(c), '{'+unicodedata.name(c)+'}')
    except Exception:
        print('!ERR')