本文整理匯總了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