-
함수 내에서 global변수 선언과 사용
>>> def f(): ... global g ... print('g' in globals()) ... if('g' not in globals()): ... g = 0 ... >>> f() False >>> f() True >>> del g >>> f() False >>> f() True >>> g 0
'Python' 카테고리의 다른 글
Python - copy, deepcopy (0) 2020.09.04 Python - Colab 코랩 (0) 2020.09.04 Python - lambda, 람다 함수식 (0) 2020.09.04 Python - 함수 내 static변수 (0) 2020.09.04 Python - 다차원 배열 초기화 (0) 2020.09.04 Python - 최대값 최소값 얻기 (0) 2020.09.04 Python pip install 명령어 옵션 (0) 2020.08.18 Flask - Session (0) 2020.07.13