本文整理汇总了Python中re._compile方法的典型用法代码示例。如果您正苦于以下问题:Python re._compile方法的具体用法?Python re._compile怎么用?Python re._compile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类re
的用法示例。
在下文中一共展示了re._compile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pickling
# 需要导入模块: import re [as 别名]
# 或者: from re import _compile [as 别名]
def test_pickling(self):
import pickle
self.pickle_test(pickle)
import cPickle
self.pickle_test(cPickle)
# old pickles expect the _compile() reconstructor in sre module
import_module("sre", deprecated=True)
from sre import _compile
# current pickle expects the _compile() reconstructor in re module
from re import _compile
示例2: test_pickling
# 需要导入模块: import re [as 别名]
# 或者: from re import _compile [as 别名]
def test_pickling(self):
import pickle
oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
pickled = pickle.dumps(oldpat, proto)
newpat = pickle.loads(pickled)
self.assertEqual(newpat, oldpat)
# current pickle expects the _compile() reconstructor in re module
from re import _compile
示例3: install
# 需要导入模块: import re [as 别名]
# 或者: from re import _compile [as 别名]
def install():
"""Install the hooks for measuring import and regex compile time."""
__builtins__['__import__'] = timed_import
re._compile = timed_compile
示例4: uninstall
# 需要导入模块: import re [as 别名]
# 或者: from re import _compile [as 别名]
def uninstall():
"""Remove the import and regex compile timing hooks."""
__builtins__['__import__'] = _real_import
re._compile = _real_compile