如何在Python正则表达式中使用通配符?
以下代码使用Python正则表达式中的 .(点)作为通配符,该通配符代表除换行符以外的任何字符。
更多Python相关文章,请阅读:Python 教程
例子
import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)
输出
此代码给出以下输出:
['this', 'thus']
以下代码使用Python正则表达式中的 .(点)作为通配符,该通配符代表除换行符以外的任何字符。
更多Python相关文章,请阅读:Python 教程
import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)
此代码给出以下输出:
['this', 'thus']
极客教程