从python输出中删除字符

时间:2015-07-08 19:31:05

标签: python regex web-scraping character

我写了一个PYTHON代码来打印推荐的产品ID,其产品ID是某个产品。我得到的输出为: -

  ['503821321','503821331','504821322','503821343']

我希望输出为: -

   503821321, 503821331, 504821322, 503821343

我该怎么办?提前谢谢。

2 个答案:

答案 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'