当前位置:主页 > 软件编程 > Python代码 >

python 将list转成字符串,中间用符号分隔的方法

时间:2021-08-21 09:10:05 | 栏目:Python代码 | 点击:

如下所示:

data = [1,2,3,4]
print "|".join(str(i) for i in data)

如果data中有中文:

import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )

您可能感兴趣的文章:

相关文章