在Python中连接字符串中的字符列表的优雅方法

Yul*_*a V 2 python string list concatenation char

可能重复:
如何以最佳方式将字符列表连接到字符串?

我有一个字符列表:

['h', 'e', 'l', 'l', 'o']
Run Code Online (Sandbox Code Playgroud)

有没有办法在不需要类似'for'循环的字符串'hello'中连接这种列表的元素?谢谢.

Ósc*_*pez 10

这是在Python中连接字符串的常用方法:

''.join(list_of_chars)
Run Code Online (Sandbox Code Playgroud)

事实上,这是推荐的方式 - 出于可读性和效率的原因.例如:

''.join(['h', 'e', 'l', 'l', 'o'])
=> 'hello'
Run Code Online (Sandbox Code Playgroud)