教程集 www.jiaochengji.com
教程集 >  Python编程  >  Python入门  >  正文 python中数组怎么转换为字符串

python中数组怎么转换为字符串

发布时间:2021-03-26   编辑:jiaochengji.com
教程集为您提供python中数组怎么转换为字符串等资源,欢迎您收藏本站,我们将为您提供最新的python中数组怎么转换为字符串资源

1、数组转字符串

#方法1
arr = ['a','b']
str1 = ''.join(arr)
 
#方法2
arr = [1,2,3]
#str = ''.join(str(i) for i in arr)#此处str命名与str函数冲突!
str2 = ''.join(str(i) for i in arr)

2、字符串转数组

#方法一
str_x = 'avfg'
st_list = list(str_x)  #使用list()
 
#方法二
list_str = []
list_str.extend(str_x )
 
#方法三
list_str = [v for v in str_x]

python学习网,免费的在线学习python平台,欢迎关注!

您可能感兴趣的文章:
python怎么把string变为hex
python怎么把时间转换为时间戳
php怎么把数组转为字符串?
python中数组怎么转换为字符串
python怎么连接字符串
python怎么替换字符串的内容
js字符串数组相互转换
php怎么把字符串转换成数组?
python怎么更改字符串后几位
Python中eval有什么用

[关闭]
~ ~