python 列表转换成字符串输出

列表转换成字符串输出

例如:我的列表是:
a=[1, 0, 0, 0, 0, 0, 0, 0]
然后输出100000
字符之间有无空格:
没有空格:

1
"".join(map(int, a))

 

有空格:

1
" ".join([str(a[i])+str(a[i+1]) for i in range(0, len(a),2)])

 

字符的类型需要修改,int或者str其他类型。

原文地址:http://www.aisun.org/2017/10/Python+list+str/

posted @ 2017-10-09 16:17  枫小Q  阅读(8860)  评论(0编辑  收藏  举报