使用split()默认以空格进行分割 最后创建一个新的列表输出
>>> a = 'to be or not to be'
>>> a
'to be or not to be'
>>> a.split()
['to', 'be', 'or', 'not', 'to', 'be']
也可以用关键字进行分割
>>> a
'to be or not to be'
>>> a.split("be")
['to ', ' or not to ', '']
>>>
使用“”.join(变量名)进行粘合
>>> "".join(a)
'to be or not to be'
>>>
也可以用其他符号粘合 如空格:
>>> " ".join(a)
'to be or not to be'
如
>>> "?".join(a)
'to?be?or?not?to?be'