如何将包含多个字符的列表转换为字符串?

时间:2015-02-15 16:50:47

标签: python python-3.x

我对编程非常陌生并且已经查找了类似问题的许多答案,但它们并没有为我产生预期的结果。你们中的任何人都可以帮助我吗? 示例代码:

shapes = ["tri", "angle"]

groupedShapes = "triangle"

1 个答案:

答案 0 :(得分:3)

根据doc's

  

string.join(words [,sep])   将单词的列表或元组与插入的sep的插入连接起来。 sep的默认值是单个空格字符。

shapes = ["tri", "angle"]
groupedShapes = "".join(shapes)
# "triangle"
相关问题