打印python列表,逗号后不带引号或空格 [英] Print python list without quotation marks or space after commas

查看:44
本文介绍了打印python列表,逗号后不带引号或空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以现在我有一个文件名列表.我要在逗号后面没有引号的情况下打印它们.

So right now I have a list of file names. I want to print them without the space after the comma and without quotation marks.

所以基本上我有一个具有以下输出的文件:

So basically I have a file that has the following output:

['1', '2', '3']

我希望输出为

1,2,3

推荐答案

使用 join 方法.

>>> your_list = ['1', '2', '3']
>>> print(', '.join(your_list))
1, 2, 3

这篇关于打印python列表,逗号后不带引号或空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆