gpt4 book ai didi

python - 如何从元组返回带引号的字符串?

转载 作者:太空宇宙 更新时间:2023-11-04 06:58:14 24 4
gpt4 key购买 nike

我有一个字符串元组,我想将其内容提取为带引号的字符串,即

tup=('string1', 'string2', 'string3')

when i do this

main_str = ",".join(tup)

#i get

main_str = 'string1, string2, string3'

#I want the main_str to have something like this

main_str = '"string1", "string2", "string3"'

加思

最佳答案

", ".join('"{0}"'.format(i) for i in tup)

", ".join('"%s"' % i for i in tup)

关于python - 如何从元组返回带引号的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1439862/

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