Asad Mahmood
Asad Mahmood

Reputation: 154

Find UTF-16 code for a character in python3

I have a file with data in Chinese language for instance i have a character 攻 and I want to find the utf-16 code of this character. how can i find it in python 3?

Upvotes: 1

Views: 134

Answers (1)

cco
cco

Reputation: 6281

Use the ord function.

print(hex(ord(u'攻')))

prints 0x653b

Upvotes: 2

Related Questions