python字符串与列表基础

#字符串与列表
#列表转为字符串
list_new = [‘hello’,‘world’,’!’]
str2= ‘’.join(list_new)
print(str2)
#字符串转为列表
str_new = ‘hello,world’
ret1 = str_new.split()
print(ret1)
#列表转为字符串
list_new = [‘string’ ‘is’ ‘string’]
str1 = ‘’
for i in list_new:
str1 += i
print(str1)

猜你喜欢

转载自blog.csdn.net/weixin_44737399/article/details/88391848