用Unicode向右到左覆盖的打印无法正常工作
我正在尝试使用u202e
Unicode RLO在Python中直接打印一些东西,但它不起作用。我在MACOS 12.4和11.6.7上使用Python 3.9.1、3.8.2和2.7.5尝试了ITERM2和终端。
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
当我尝试使用此格式向右打印时:print(u“ \ u202eblah”)
打印:blah
我希望输出是:
halb
我在做什么错? iterm也设置为utf-8
。
I'm trying to print something right to left in Python using the u202E
unicode RLO and it's not working. I've tried this in iTerm2 and Terminal on MacOS 12.4 and 11.6.7 using Python 3.9.1, 3.8.2, and 2.7.5.
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
When I try to print right to left using this format:print (u"\u202EBlah")
Which prints:Blah
I expect the output to be:
halB
What am I doing wrong? iTerm is set for utf-8
as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在Google Colab和Pycharm上运行以下代码会导致答案中给出的正确输出:
确保您的python版本为
3.x
,它可能是版本错误,因为它在Windows 10和Linux上正常运行。Running the following code on Google Colab and Pycharm results in the correct output given in the answer:
Make sure your Python version is
3.x
, it may be a version error, as it works well on Windows 10 and Linux.