擅长:python、mysql、java
<p>如果你有经验,我建议像其他人建议的那样学习Regex。但是,如果您正在寻找替代方法,这里有一种不使用Regex的方法。它也会产生你想要的输出。在</p>
<pre><code>string = input("Enter:") #Put your own input here.
tempList = string.replace("BUCKET",':').split(":")
outputList = []
for i in range(1,len(tempList)-1,2):
someTuple = ("BUCKET"+tempList[i],tempList[i+1])
outputList.append(someTuple)
print(outputList) #Put your own output here.
</code></pre>
<p>这将产生:</p>
^{pr2}$
<p>如果您不熟悉Regex,希望这段代码更容易理解和操作,尽管如果您熟悉如何使用它,我还是建议Regex来解决这个问题。在</p>