📜  python 局部变量 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:24.692000             🧑  作者: Mango

代码示例1
'''Local variables are those that are defined in a block '''
a = 1 #This is NOT a local variable, this is a global variable
def add():
  b = 1 #This IS a local variable
  print(b)
add()
#If we tried to print(b) outside of the add() function, we would get an error