python - join()转义的问题
黄舟
黄舟 2017-04-18 10:15:44
0
1
353
t = ['[', '"', '123', '"', ',"', 'haha', '"', ',"', '"', ',"', '**\\t', '"', ',"', '3709**********3125', '"', ',"', '', '"', ']']
print "".join(t)

>>> ["123","haha","","**\t","3709**********3125",""]

有什么办法可以让join返回的的时候不转义\,返回原始值么?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
洪涛

Can be used

'{!r}'.format(s)

Make s unescaped, ok for lists

t = list(map(lambda s:'{!r}'.format(s),t))

To handle it uniformly.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!