例1.
n1 = "I love iThome 2022 "
print(n1.split())
輸出為:['I', 'love', 'iThome', '2022']
例2.
n1 = "I love iThome 2022 "
print(n1.split())
輸出為:['I', 'love', 'iThome', '2022']
例3.
n1 = "I love iThome 2022 "
print(n1.split(" "))
輸出為:['I', '', '', '', '', '', '', '', '', '', '', '', '', 'love', 'iThome', '2022', '']
例4.
n1 = "I! love! iThome! 2022!"
print(n1.split("!"))
輸出為:['I', ' love', ' iThome', ' 2022', '']
例5.
n1 = "I! love! iThome! 2022!"
print(n1.split("!", 1))
輸出為:['I', ' love! iThome! 2022!']