字符串编码/解码

时间:2011-02-04 09:03:12

标签: python encoding

=?KOI8-R 2 B 4 W1JFUS0wMDI1NDEtNDc5NzddIO / h7yAi89TSz8rGwdLGz9IiIDs =?= \ r \ n \ T =?KOI8-R 2 B 4 Ry43MjkgKDEwKQ ==?='

如何将其转换为可读的内容? 谢谢!

2 个答案:

答案 0 :(得分:11)

>>> email.header.decode_header('=?KOI8-R?B?W1JFUS0wMDI1NDEtNDc5NzddIO/h7yAi89TSz8rGwdLGz9IiIDs=?=\r\n\t=?KOI8-R?B?Ry43MjkgKDEwKQ==?=')
[('[REQ-002541-47977] \xef\xe1\xef "\xf3\xd4\xd2\xcf\xca\xc6\xc1\xd2\xc6\xcf\xd2" ;G.729 (10)', 'koi8-r')]
>>> print '[REQ-002541-47977] \xef\xe1\xef "\xf3\xd4\xd2\xcf\xca\xc6\xc1\xd2\xc6\xcf\xd2" ;G.729 (10)'.decode('koi8-r')
[REQ-002541-47977] ОАО "Стройфарфор" ;G.729 (10)

答案 1 :(得分:3)

这是RFC 2047中指定的编码字编码。

email package应该能够处理这种格式。