'글로벌변수'에 해당되는 글 1건

  1. 2019.05.21 python 글로벌 변수 메소드에서 사용방법
Phython2019. 5. 21. 12:34

 

글로벌 변수를 사용할려면  global을 메소드안에서 선언해 줘야 한다.

x = 10

 

def foo():

 global x

 x += 1

 print x

 

foo()

https://eli.thegreenplace.net/2011/05/15/understanding-unboundlocalerror-in-python

'Phython' 카테고리의 다른 글

beautifulsoup에서 링크만 빼는법  (0) 2019.05.28
시놀리지에서 vpn client 사용하는 방법  (0) 2019.05.28
파이썬에서 텔레그램 메세지 에코  (0) 2019.05.21
파이썬 simple json 파싱  (0) 2019.05.17
파이썬 web request  (0) 2019.05.17
Posted by 동동(이재동)