字符串、列表、元组之间的相互转换主要使用是三个函数:str(),tuple(),list()和join()
str1 = 'hello world'
lis = list(str1)
print('输出结果是:',lis)
输出结果是: ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
str1 = 'hello world'
tu1 = tuple(str1)
print(tu1)
('h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd')
lis = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
str1 = ''.join(lis)
print(str1)
hello world
lis = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
tu1 = tuple(lis)
print(tu1)
('h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd')
tu1 = ('h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd')
str1 = ''.join(tu1)
print(str1)
hello world
tu1 = ('h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd')
lis = list(tu1)
print(lis)
['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']