相关疑难解决方法(0)

直接打印家庭表情符号,使用 U+200D 零宽度连接器,对比通过列表

在通过print直接打印带有家庭表情符号的字符串以及在列表中时,我发现了一些意想不到的差异。下面的程序

family = '???'
print(family)
print([family])
Run Code Online (Sandbox Code Playgroud)

产出

???
['\u200d\u200d\u200d']
Run Code Online (Sandbox Code Playgroud)

当我期望它输出时

???
['???']
Run Code Online (Sandbox Code Playgroud)

多字符字形的另一种情况

man_with_skin_tone_modifier = ''
print(man_with_skin_tone_modifier)
print([man_with_skin_tone_modifier])
Run Code Online (Sandbox Code Playgroud)

输出如我所料:


['']
Run Code Online (Sandbox Code Playgroud)

为什么是这样?


上下文:我在为/sf/answers/3495148191/编写答案时发现了这一点,它在 OS X 上使用 Python 3.6.5。

python unicode python-3.x emoji

5
推荐指数
1
解决办法
1088
查看次数

标签 统计

emoji ×1

python ×1

python-3.x ×1

unicode ×1