原创 re Python正則

re.compile() 生成正則對象效率最高# encoding: UTF-8import re # 將正則表達式編譯成Pattern對象pattern = re.compile(r'hello') # 使用Pattern匹配文本,獲得匹