**# ‘’‘列表与字符串的相互转换’’’ str_new = 'hello world' str_to_list = list(str_new) print(list(str_new)) print(str_new.split()) 1. 2. 3. 4. 5. print(’###’) list_new = ['hello','world','!'] str1 = '' for i in list_new: str1 +=i print(str1) #pri...
要将字符串转换为元组,可以使用内置的tuple()函数。这个函数可以接受一个可迭代对象(如字符串),并将其转换为元组。以下是一个示例: string = "Hello, World!" tuple = tuple(string) print(tuple) 复制代码 输出: ('H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd',...