繁体   English   中英

将元组中的所有条目添加到一个字符串中

[英]Adding all entries in tuple into one string

('word1', 'word2')

如果我有一个元组,如何将元组中的所有单词添加到一个字符串中?

所需的 output:

word1 word2

使用str.join

tpl = ("word1", "word2")

s = " ".join(tpl)
print(s)

印刷:

word1 word2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM