[英]how to clear some characters by regex?
import re, sys
m = re.sub('(','',m)
我想清除“(”,“)”。 我該怎么辦?
不要對此類簡單內容使用正則表達式; 使用翻譯:
>>> str = "This is a (string) (example)..."
>>> str.translate(None, "()")
'This is a string example...'
>>>
p = re.compile(r'<a>.*?</a>')
my_source = p.sub('<a></a>', my_source, re.DOTALL)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.