我有這樣蟒蛇:清理字符串
somestring='in this/ string/i have many. interesting.occurrences of {different chars} that need to .be removed '
這裏的字符串是我想要的結果:
somestring='in this string i have many interesting occurrences of different chars that need to be removed'
我開始手工做各種.replace
,但有這麼許多不同的組合,我認爲必須有一個更簡單的方法。也許有一個圖書館已經這樣做?
沒有人知道我該如何清理這個字符串>?
wowowow !!這是相當驚人的!我在哪裏可以讀到關於這個圖書館? – 2010-09-01 19:11:35
@user:這只是一個簡單的正則表達式。該庫位於http://docs.python.org/library/re.html。有關正則表達式的更多信息,請參見http://www.regular-expressions.info/。 – kennytm 2010-09-01 19:13:06
http://docs.python.org/library/re.html – leoluk 2010-09-01 19:13:17