Python正则表达式split()字符串

has*_*__x 4 python regex string split

我对python中的正则表达式很新.我有以下字符串,并希望将它们分为五个类别.我只是使用split()但它会根据空格分开.

s = "1 0 A10B 1/00 Description: This is description with spaces"
sp = s.split()
>>> sp
["1", "0", "A10B", "1/00", "Description:", "This", "is", "description", "with", "spaces"]
Run Code Online (Sandbox Code Playgroud)

如何编写正则表达式使其像这样拆分:

 ["1", "0", "A10B", "1/00", "Description: This is description with spaces"]
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?谢谢!

Rom*_*huk 10

您可以简单地指定一些拆分:

s.split(' ', 4)
Run Code Online (Sandbox Code Playgroud)