在ShiftJI中编码/解码后,字符转换为\

2024-05-14 13:47:51 发布

您现在位置:Python中文网/ 问答频道 /正文

这怎么可能?是虫子吗?(在Python2.7.12和Python3.5.1中的行为相同。)

In [1]: yen = u'\u00A5'

In [2]: print(yen)
¥

In [3]: yen_after_encoding_decoding = yen.encode('shift-jis').decode('shift-jis')

In [4]: print(yen_after_encoding_decoding)
\

In [5]: yen
Out[5]: '¥'

In [6]: yen_after_encoding_decoding
Out[6]: '\\'

In [7]:

日元的shift-jis编码与反斜杠的ASCII编码相同,所以这可能是相关的。但还是很奇怪!你知道吗


Tags: in编码shiftoutencodingencodeprintdecode

热门问题