Get the App
SLTechnology News&Howtos  ›  Servers  › 

Influence value of Python function

Shulou Source: shulou.com Published: 2022-06-03 06:09:30 10月04日 Update

Environment: Python 2.7

Solve the problem that the function does not affect the value of the variable.

#-*-coding: utf-8-*-a = 0def b (): global an a = 1 a=a+1 print a return adef c (): global an a=a+1 print a return adef d (): print aif _ _ name__ = ='_ main__': b () c () d () c ()

Running result:

2334

Tags: Influence function environment result value problem utf-8 run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB Microsoft Shulou Technology Shulou Tech Info