파이썬 g 글로벌 키워드
예시
함수 내부에서 전역 변수를 선언하고 함수 외부에서 사용합니다.
#create a function:
def myfunction():
global x
x =
"hello"
#execute the function:
myfunction()
#x should now
be global, and accessible in the global scope.
print(x)
정의 및 사용
키워드는 전역 이 global
아닌 범위(예: 함수 내부)에서 전역 변수를 만드는 데 사용됩니다.