Python Latin-1十进制补充

时间:2018-01-31 14:04:47

标签: python character-encoding decimal iso-8859-1

使用python

ord('a')

给出

 97

但是

ord('é')

给出错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ord() expected a character, but string of length 2 found

如何获取除https://en.wikipedia.org/wiki/List_of_Unicode_characters#Latin-1_Supplement之外的ASCII(é= 233)以外的其他字母的小数?

1 个答案:

答案 0 :(得分:2)

您可以先解码它:

ord('é'.decode('utf-8'))  # outputs 233