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 怎样把列表的[]去掉的具体内容,更多请存眷资源魔其它相干文章!
标签: python教程 python编程 python使用问题 python 怎么把列表的[]去掉
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!