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所在内存空间的引用

 

posted @ 2020-06-09 23:01  abel2020  阅读(257)  评论(0编辑  收藏  举报