我对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"]
如何编写正则表达式使其拆分为这样:
^{pr2}$有人能帮忙吗?谢谢!在
您可以简单地指定多个拆分:
split()
的第二个参数是要执行的最大拆分数。如果将其设置为4,则剩余的字符串将是列表中的第5项。在不是一个完美的解决方案。但首先。在
相关问题 更多 >
编程相关推荐