如何编写 Python 正则表达式来获取模式中的零次或多次出现?\
pythonserver side programmingprogramming
* 正则表达式中的星号元字符表示其左侧的模式出现 0 次或多次
以下代码匹配并打印字符串 'chihua huahua' 中模式 '\w' 的零次或多次出现
示例
import re s = 'chihua huahua' result = re.findall(r'\w*', s) print result
输出
这给出了输出
['chihua', '', 'huahua', '']
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

