[英]How to turn a list of integers into a string of numbers?
I'd like to turn 我想转身
[1,2,3,4,5,4,3,2,1]
into 进入
['1','2','3','4','5','4','3','2','1']
in preparation of doing FreqDist
. 准备做FreqDist
。
投射列表中的每个项目时,请使用内置地图功能:
newList = map(str, oldList)
Just use a simple list comprehension 只需使用简单的列表理解
>>> myar=[1,2,3,4,5,4,3,2,1]
>>> [str(i) for i in myar]
['1', '2', '3', '4', '5', '4', '3', '2', '1']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.