首页 > 编程语言 >python 中如何将列表中的数值转换为字符串

python 中如何将列表中的数值转换为字符串

时间:2022-08-18 08:33:07浏览次数:53  
标签:test1 200 test2 aaa python 列表 字符串 100

 

001、

>>> test1 = ["aaa", 100, 200]
>>> test1
['aaa', 100, 200]
>>> test2 = [str(k) for k in test1]      ## 将列表test1中的数值转换为字符串
>>> test2
['aaa', '100', '200']

 

002、

>>> test1 = ("aaa", 100, 200)
>>> test1
('aaa', 100, 200)
>>> test2 = [str(k) for k in test1]        ## 同样适用于元组
>>> test2
['aaa', '100', '200']
>>> tuple(test2)
('aaa', '100', '200')

 

标签:test1,200,test2,aaa,python,列表,字符串,100
From: https://www.cnblogs.com/liujiaxin2018/p/16597486.html

相关文章