Python 将字符串列表转换为一个字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36094979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert a list of strings into one string
提问by cccg03
I'm super new to any sort of programming, so forgive my ignorance for not knowing how to do something that seems so simple.
我对任何类型的编程都是超级新手,所以请原谅我不知道如何做一些看起来如此简单的事情的无知。
All I'd like to do is take any array of strings (call it name), let's say:
我想要做的就是获取任何字符串数组(称之为名称),让我们说:
["John", "Charles", "Smith"]
and removeit from the list and turn it into a string:
并将其从列表中删除并将其转换为字符串:
John Charles Smith
I can't seem to get my head around this and couldn't find a similar post.
我似乎无法解决这个问题,也找不到类似的帖子。
回答by projetmbc
Just use:
只需使用:
" ".join(["John", "Charles", "Smith"])