【发布时间】:2014-04-08 13:55:05
【问题描述】:
我正在尝试解码下面列表中的字符串。它们都以 utf-8 格式编码。
_strs=['."\n\nThe vicar\'',':--\n\nIn the', 'cathedral']
预期输出:
['.The vicar', ':--In the', 'cathedral']
我的尝试
>>> for x in _str:
x.decode('string_escape')
print x
'."\n\nThe vicar\''
."
The vicar'
':--\n\nIn the'
:--
In the
'cathedral'
cathedral
>>> print [x.decode('string_escape') for x in _str]
['."\n\nThe vicar\'', ':--\n\nIn the', 'cathedral']
两次尝试都失败了。 有什么想法吗?
【问题讨论】: