我试图在Python中使用u202E
unicode RLO从右到左打印一些东西,它不起作用。我在MacOS 12.4和11.6.7上使用Python 3.9.1, 3.8.2和2.7.5在iTerm2和Terminal中尝试过。
[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
我期望输出是:
没什么
我做错了什么?也为utf-8
设置了term。
在Google Colab和Pycharm上运行以下代码将得到答案中给出的正确输出:
import sys
print(sys.getdefaultencoding())
print(u"u202EBlah")
utf - 8等等
确保你的Python版本是3.x
,这可能是一个版本错误,因为它在Windows 10和Linux上运行良好。