我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用sys.py2_modules()。
def cache_py2_modules(): """ Currently this function is unneeded, as we are not attempting to provide import hooks for modules with ambiguous names: email, urllib, pickle. """ if len(sys.py2_modules) != 0: return assert not detect_hooks() import urllib sys.py2_modules['urllib'] = urllib import email sys.py2_modules['email'] = email import pickle sys.py2_modules['pickle'] = pickle # Not all Python installations have test module. (Anaconda doesn't, for example.) # try: # import test # except ImportError: # sys.py2_modules['test'] = None # sys.py2_modules['test'] = test # import dbm # sys.py2_modules['dbm'] = dbm