Python拉丁语-1十进制补充

Python拉丁语-1十进制补充,python,character-encoding,decimal,iso-8859-1,Python,Character Encoding,Decimal,Iso 8859 1,用python ord('a') 给予 但是 给出一个错误 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: ord() expected a character, but string of length 2 found 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 TypeError:ord()应为字符,但找到长度为2的字符串 如何获取A

用python

ord('a')
给予

但是

给出一个错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ord() expected a character, but string of length 2 found
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
TypeError:ord()应为字符,但找到长度为2的字符串

如何获取ASCII(é=233)以外的其他字母的小数点,如中所示?

您可以先对其进行解码:

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

您可以先对其进行解码:

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

您使用的是什么python版本?我在Python2和Python3中尝试了同样的方法,两种方法都很好。我在Python2.7.9中也遇到了同样的问题,但在Python3.4.2中效果很好。为了复制,您需要一个用UTF-8编码但缺少
编码:UTF-8
注释的文件。我相信这只会影响Python2。您使用的是什么Python版本?我在Python2和Python3中尝试了同样的方法,两种方法都很好。我在Python2.7.9中也遇到了同样的问题,但在Python3.4.2中效果很好。为了复制,您需要一个用UTF-8编码但缺少
编码:UTF-8
注释的文件。我认为这只会影响Python 2。
ord('é'.decode('utf-8'))  # outputs 233