点击运行
#!/usr/bin/python3 total = 0; # 这是全局变量 # Function definition is here def sum( arg1, arg2 ): # 两个参数进行相加,并返回结果。" total = arg1 + arg2; # Here total is local variable. print ("Inside the function local total : ", total) return total; # 调用 sum 函数 sum( 10, 20 ); print ("Outside the function global total : ", total)
运行结果 :
正在执行...