【发布时间】:2018-08-07 07:13:51
【问题描述】:
我使用表情符号的 unicode 值创建了两个包含正面和负面表情符号的数组:
positive = [
u'\U0001F600',
u'\U0001F601',
u'\U0001F602',
u'\U0001F923',
u'\U0001F603',
u'\U0001F604',
u'\U0001F605',
u'\U0001F606',
u'\U0001F609',
u'\U0001F60A',
u'\U0001F60B',
u'\U0001F60E',
u'\U0001F60D',
u'\U0001F618',
u'\U0001F617',
u'\U0001F619',
u'\U0001F61A',
u'\U0000263A',
u'\U0001F642',
u'\U0001F917',
u'\U0001F60F',
u'\U0001F60C',
u'\U0001F61B',
u'\U0001F61C',
u'\U0001F61D',
u'\U0001F924',
u'\U0001F643',
u'\U0001F62C']
negative = [
u'\U0001F610',
u'\U0001F611',
u'\U0001F636',
u'\U0001F644',
u'\U0001F60F',
u'\U0001F623',
u'\U0001F625',
u'\U0001F62E',
u'\U0001F910',
u'\U0001F62F',
u'\U0001F62A',
u'\U0001F62B',
u'\U0001F634',
u'\U0001F612',
u'\U0001F613',
u'\U0001F614',
u'\U0001F615',
u'\U0001F641',
u'\U0001F616',
u'\U0001F61E',
u'\U0001F61F',
u'\U0001F624',
u'\U0001F622',
u'\U0001F62D',
u'\U0001F626',
u'\U0001F627',
u'\U0001F628',
u'\U0001F629',
u'\U0001F630',
u'\U0001F631',
u'\U0001F635',
u'\U0001F621',
u'\U0001F620',
u'\U0001F637',
u'\U0001F912',
u'\U0001F915',
u'\U0001F922',
u'\U0001F927']
但是,例如,当我打印 positive[0] 时,我得到的是这个奇怪的字符而不是表情符号:
�
我正在使用 Amazon Linux 和 python-3.4 开发 EC2 机器。 在我的 Macbook 上,相同的代码可以正常工作。
【问题讨论】:
-
我得到一个表情符号。
-
在 macOS 终端上也适用于我。可能与您使用的控制台模拟器有关。
-
这取决于最终用户环境能够解释 unicode 集。特定字体可能没有代表预期字符的字符,因此显示默认字符(即带问号的菱形)。
-
问题出在“屏幕”上,如果我不在它下面运行,它可以正常工作。
标签: python python-3.x utf-16