![图片[1]-Python怎么将列表转字符串-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5e8703373d3ac649.jpg)
Python怎么将列表转字符串
例子:
将列表temp_list = ['h', 'e', 'l', 'l', 'o'] 转换成字符串'hello',代码如下:
temp_list=['h','e','l','l','o'] result=''.join(temp_list) print(result) hello
推荐学习《Python教程》。
字符串对象的方法join其描述如下:
defjoin(self,iterable):#realsignatureunknown;restoredfrom__doc__ """ S.join(iterable)->str Returnastringwhichistheconcatenationofthestringsinthe iterable.TheseparatorbetweenelementsisS. """ return""原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END

















































暂无评论内容