如何忽略转义\ python列表? [英] How to ignore the escaping \ python list?
本文介绍了如何忽略转义\ python列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想忽略以下代码中的转义字符。
I want to ignore the escape character in the following code.
>>> a=['\%']
>>> print a
['\\%']
我想输出像 [ '\%']
。有没有办法这样做?
I want to output like ['\%']
. Is there any way to do that?
推荐答案
使用 string_escape
code> unicode_escape encoding(见 Python特定编码):
Using string_escape
, unicode_escape
encoding (See Python Specific Encodings):
>>> a = ['\%']
>>> print str(a).decode('string_escape')
['\%']
>>> print str(a).decode('unicode_escape')
['\%']
这篇关于如何忽略转义\ python列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文