gpt4 book ai didi

python - 元组到字符串

转载 作者:太空狗 更新时间:2023-10-29 20:38:22 25 4
gpt4 key购买 nike

我有一个元组。

tst = ([['name', u'bob-21'], ['name', u'john-28']], True)

我想把它转换成一个字符串..

print tst2
"([['name', u'bob-21'], ['name', u'john-28']], True)"

这样做的好方法是什么?

谢谢!

最佳答案

tst2 = str(tst)

例如:

>>> tst = ([['name', u'bob-21'], ['name', u'john-28']], True)
>>> tst2 = str(tst)
>>> print tst2
([['name', u'bob-21'], ['name', u'john-28']], True)
>>> repr(tst2)
'"([[\'name\', u\'bob-21\'], [\'name\', u\'john-28\']], True)"'

关于python - 元组到字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3886669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com