如何使用 Python 正则表达式中的通配符?
以下代码使用 Python 正则表达式 .()dot 字符表示通配符,它代表任何字符(换行符除外)。
示例
import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)输出
它产生此输出
['this', 'thus']
广告
以下代码使用 Python 正则表达式 .()dot 字符表示通配符,它代表任何字符(换行符除外)。
import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)它产生此输出
['this', 'thus']