我有一個(gè)帳戶列表:list1 = ['1234','3456','2345','5543','1344','5679','6433','3243','0089']我需要的輸出是一個(gè)字符串:print(output):'1234','3456','2345','5543','1344','5679','6433','3243','0089'
2 回答

慕娘9325324
TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊
您可以將所有值與字符串聯(lián)接,然后在字符串之前和之后添加一個(gè),如下所示:','
'
"'{0}'".format("','".join(list1))

慕尼黑5688855
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊
>>> 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'
添加回答
舉報(bào)
0/150
提交
取消