파이썬[Python]: sys - modules 변수
sys 모듈 - modules 변수(variable)
/// 설명
모듈 이름과 현재 적재(loaded)되어 있는 모듈이 표현되어 있는 딕셔너리를 반환합니다. 딕셔너리를 치환하는 것은 파이썬의 오류를 야기할 수 있습니다. 대신, sys.modules.copy() 나 tuple(sys.modules)를 사용하시기 바랍니다.
※ 형식
sys.modules
※ 형식
sys.modules
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | import sys from pprint import pprint pprint(sys.modules.copy()) # {'__main__': <module '__main__' from 'D:\\......\\Computer_Program\\Py\\Practice\\main.py'>, # '_abc': <module '_abc' (built-in)>, # '_bootlocale': <module '_bootlocale' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\_bootlocale.py'>, # '_codecs': <module '_codecs' (built-in)>, # '_codecs_kr': <module '_codecs_kr' (built-in)>, # '_collections': <module '_collections' (built-in)>, # '_collections_abc': <module '_collections_abc' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\_collections_abc.py'>, # '_frozen_importlib': <module 'importlib._bootstrap' (frozen)>, # '_frozen_importlib_external': <module 'importlib._bootstrap_external' (frozen)>, # '_functools': <module '_functools' (built-in)>, # '_heapq': <module '_heapq' (built-in)>, # '_imp': <module '_imp' (built-in)>, # '_io': <module 'io' (built-in)>, # '_locale': <module '_locale' (built-in)>, # '_multibytecodec': <module '_multibytecodec' (built-in)>, # '_operator': <module '_operator' (built-in)>, # '_signal': <module '_signal' (built-in)>, # '_sitebuiltins': <module '_sitebuiltins' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\_sitebuiltins.py'>, # '_sre': <module '_sre' (built-in)>, # '_stat': <module '_stat' (built-in)>, # '_thread': <module '_thread' (built-in)>, # '_warnings': <module '_warnings' (built-in)>, # '_weakref': <module '_weakref' (built-in)>, # 'abc': <module 'abc' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\abc.py'>, # 'builtins': <module 'builtins' (built-in)>, # 'codecs': <module 'codecs' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\codecs.py'>, # 'collections': <module 'collections' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\collections\\__init__.py'>, # 'collections.abc': <module 'collections.abc' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\collections\\abc.py'>, # 'contextlib': <module 'contextlib' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\contextlib.py'>, # 'copyreg': <module 'copyreg' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\copyreg.py'>, # 'encodings': <module 'encodings' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\encodings\\__init__.py'>, # 'encodings.aliases': <module 'encodings.aliases' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\encodings\\aliases.py'>, # 'encodings.cp949': <module 'encodings.cp949' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\encodings\\cp949.py'>, # 'encodings.latin_1': <module 'encodings.latin_1' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\encodings\\latin_1.py'>, # 'encodings.utf_8': <module 'encodings.utf_8' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\encodings\\utf_8.py'>, # 'enum': <module 'enum' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\enum.py'>, # 'functools': <module 'functools' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\functools.py'>, # 'genericpath': <module 'genericpath' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\genericpath.py'>, # 'heapq': <module 'heapq' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\heapq.py'>, # 'importlib': <module 'importlib' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\importlib\\__init__.py'>, # 'importlib._bootstrap': <module 'importlib._bootstrap' (frozen)>, # 'importlib._bootstrap_external': <module 'importlib._bootstrap_external' (frozen)>, # 'importlib.abc': <module 'importlib.abc' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\importlib\\abc.py'>, # 'importlib.machinery': <module 'importlib.machinery' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\importlib\\machinery.py'>, # 'importlib.util': <module 'importlib.util' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\importlib\\util.py'>, # 'io': <module 'io' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\io.py'>, # 'itertools': <module 'itertools' (built-in)>, # 'keyword': <module 'keyword' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\keyword.py'>, # 'marshal': <module 'marshal' (built-in)>, # 'mpl_toolkits': <module 'mpl_toolkits' (namespace)>, # 'nt': <module 'nt' (built-in)>, # 'ntpath': <module 'ntpath' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\ntpath.py'>, # 'operator': <module 'operator' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\operator.py'>, # 'os': <module 'os' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\os.py'>, # 'os.path': <module 'ntpath' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\ntpath.py'>, # 'pprint': <module 'pprint' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\pprint.py'>, # 'pywin32_bootstrap': <module 'pywin32_bootstrap' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\site-packages\\win32\\lib\\pywin32_bootstrap.py'>, # 'pywin32_system32': <module 'pywin32_system32' (namespace)>, # 're': <module 're' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\re.py'>, # 'reprlib': <module 'reprlib' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\reprlib.py'>, # 'site': <module 'site' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\site.py'>, # 'sre_compile': <module 'sre_compile' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\sre_compile.py'>, # 'sre_constants': <module 'sre_constants' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\sre_constants.py'>, # 'sre_parse': <module 'sre_parse' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\sre_parse.py'>, # 'stat': <module 'stat' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\stat.py'>, # 'sys': <module 'sys' (built-in)>, # 'time': <module 'time' (built-in)>, # 'types': <module 'types' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\types.py'>, # 'typing': <module 'typing' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\typing.py'>, # 'typing.io': <class 'typing.io'>, # 'typing.re': <class 'typing.re'>, # 'warnings': <module 'warnings' from 'C:\\Users\\psych\\anaconda3\\envs\\Practice\\lib\\warnings.py'>, # 'winreg': <module 'winreg' (built-in)>, # 'zipimport': <module 'zipimport' (frozen)>} | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기