1 str.split(str="", num=string.count(str))
參數:spa
1 a = '1,2,3,4' 2 a = a.split(',') #以逗號爲分隔符 3 print(a) 4 輸出:['1', '2', '3', '4']
栗子2:code
1 a = '1-2-3-4' 2 a = a.split('-') #以橫杆爲分隔符 3 print(a) 4 輸出:['1', '2', '3', '4']
栗子3:blog
a = '1-2-3-4' a = a.split('-',1) #以橫杆爲分隔符,分隔次數爲1 print(a) 輸出:['1', '2-3-4']