好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python怎么把列表的[]去掉

python 怎么把列表的[]去掉?下面给大家讲解具体方法:

LIST = ['Python','problem','whatever']
print(LIST) 

运行结果:

[Python, problem, whatever] 

相关推荐:《Python视频教程》

如果想从 输出中删除方括号可以将其转换为字符串,而不是直接打印列表:

>>> LIST = ['Python','php','java']
>>> print(", ".join(LIST))
Python, php, java 

如果列表中的元素不是字符串,您可以使用repr(如果您想要引用字符串)或str(如果没有)将它们转换为字符串,如下所示:

>>> LIST = [1, "foo", 3.5, { "hello": "bye" }]
>>> print(", ".join(repr(e) for e in LIST))
1, 'foo', 3.5, {'hello': 'bye'} 

以上就是python 怎么把列表的[]去掉的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于python怎么把列表的[]去掉的详细内容...

  阅读:38次