将python列表转换为字符串,并以有效方式将逗号分隔[closed]

问题描述 投票:-7回答:2

我有一个帐号列表:

list1 = ['1234','3456','2345','5543','1344','5679','6433','3243','0089']

我需要的输出是字符串:

[print(output)'1234','3456','2345','5543','1344','5679','6433','3243','0089'

python
2个回答
3
投票

您可以将所有值与','结合在一起,然后在这样的字符串前后添加'


0
投票
>>> list1 = ['1234','3456','2345','5543','1344','5679','6433','3243','0089']
>>> print(','.join(["'{0}'".format(s) for s in list1]))
'1234','3456','2345','5543','1344','5679','6433','3243','0089'
© www.soinside.com 2019 - 2024. All rights reserved.