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 怎样把列表的[]去掉的细致内容,更多请关注ki4网别的相干文章!