![python 怎么把列表的[]去掉 python 怎么把列表的[]去掉](https://www.mshxw.com/file/tupian/20220417/ldswxk3vz4q.jpg)
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 怎么把列表的[]去掉的详细内容,更多请关注考高分网其它


