简体   繁体   English

将整数和字符串的元组转换为字符串

[英]Converting Tuple of integers and strings to just a string

I want to convert a tuple which contains strings and integers into a string, I have tried using the '.join' method but this only seems to work for a tuple of strings. 我想将包含字符串和整数的元组转换为字符串,我尝试使用'.join'方法,但这似乎只适用于字符串元组。

Can anyone help me? 谁能帮我? I am using Python 3.5, thanks! 我正在使用Python 3.5,谢谢!

" ".join(map(str,my_list))

I guess ... 我猜 ...

or " ".join(str(x) for x in my_list) " ".join(str(x) for x in my_list)

This Might Help 这可能有帮助

>>> a = ( "aty",3,"bob",5,6)
>>> tuple(map( str , a ) )
('aty', '3', 'bob', '5', '6')

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

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