字符串示例 - >预期产出
" 1 1 1-1 SOME MESSAGE HERE" --> ['1','1','1-1','SOME MESSAGE HERE']
" 71 91 1-1 SOME MESSAGE HERE" --> ['71','91','1-1','SOME MESSAGE HERE']
" 171 191 1-1 SOME MESSAGE HERE" --> ['171','191','1-1','SOME MESSAGE HERE']
" 1171 1191 1-1 SOME MESSAGE HERE" --> ['1171','1191','1-1','SOME MESSAGE HERE']
答案 0 :(得分:2)
x = " 1 1 1-1 SOME MESSAGE HERE"
y = x.split(None, 3)
print (y) # ['1', '1', '1-1', 'SOME MESSAGE HERE']
x = " 1 1 1-1 SOME MESSAGE HERE"
y = x.split(maxsplit=3)
print (y) # ['1', '1', '1-1', 'SOME MESSAGE HERE']