字符串列表的互相转换

将字符串helloworld转换为列表['helloworld']

字符串.split("分隔符")返回的是列表类型的对象

str1 = 'helloworld'
list1 = str1.split()
print(list1) #['helloworld']

将列表['helloworld']转换为字符串helloworld

拼接字符串.join(列表)返回的是字符串类型的对象

list1 = ['helloworld']
str1 = "".join(list1)
print(str1)  #helloworld

猜你喜欢

转载自blog.csdn.net/qq_35169931/article/details/85089552
今日推荐