我如何找到两个子字符串('123STRINGabc' -> '字符串')之间的字符串?
我现在的方法是这样的:
>>> start = 'asdf=5;'
>>> end = '123jasd'
>>> s = 'asdf=5;iwantthis123jasd'
>>> print((s.split(start))[1].split(end)[0])
iwantthis
然而,这似乎非常低效且不符合python规则。有什么更好的方法来做这样的事情吗?
忘了说: 字符串可能不是以start和end开始和结束的。他们可能会有更多的字符之前和之后。