相关疑难解决方法(0)

连接列表的元素

我有一个列表,就像l=['a', 'b', 'c'] 我想要一个像'abc'这样的字符串.所以实际上结果是l[0]+l[1]+l[2],也可以写成

s = ''
for i in l:
    s += i
Run Code Online (Sandbox Code Playgroud)

有没有办法更优雅地做到这一点?

python string concatenation

8
推荐指数
1
解决办法
9313
查看次数

标签 统计

concatenation ×1

python ×1

string ×1