12 函数返回值的地址引用

def fun():
    s="python"
    print("%s address is %d" % (s,id(s)))
    return s

f=fun()
print("%s address is %d" % (f,id(f)))

运行结果:
python address is 3049855780144
python address is 3049855780144

函数返回时,通过对地址的引用得到python ,即r 和s都是对py所在内存空间的引用

相关推荐