我有一個類似于the "cow"1 jumped "over"2 the moon and the "spoon"3... this happened 123 times
我只想洗掉引號后面的數字的字串:
the "cow" jumped "over" the moon and the "spoon"... this happened 123 times
uj5u.com熱心網友回復:
嘗試這個:
請參閱此處的正則運算式模式。
import re
string = 'the "cow"1 jumped "over"2 the moon and the "spoon"3... this happened 123 times'
pat = r"(?<=\")(\d )"
out = re.sub(pat, "", string)
print(out)
the "cow" jumped "over" the moon and the "spoon"... this happened 123 times
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/510268.html
上一篇:如何替換url中的動態內容?
