我写了一个PYTHON代码来打印推荐的产品ID,其产品ID是某个产品。我得到的输出为: -
['503821321','503821331','504821322','503821343']
我希望输出为: -
503821321, 503821331, 504821322, 503821343
我该怎么办?提前谢谢。
答案 0 :(得分:1)
In [77]: ', '.join(['503821321','503821331','504821322','503821343'])
Out[77]: '503821321, 503821331, 504821322, 503821343'
In [78]: print(', '.join(['503821321','503821331','504821322','503821343']))
503821321, 503821331, 504821322, 503821343
答案 1 :(得分:1)
foo = ['503821321','503821331','504821322','503821343']
','.join(i for i in foo)
输出:
'503821321,503821331,504821322,503821343'