Reference Or Value pass in python

本文探讨了Python中函数参数的不同传递方式。对于不可变类型如整数、字符串和元组,Python采用类似传值的方式;而对于可变类型如列表和字典,则采取引用传递的方式。这影响着函数内部对参数值的操作是否会影响外部变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Preface


(1)Pass/call-by-Reference OR Pass-by Value also exists in Python(like:Python2.7);

(2)Commonly,if such immutable type arguments as Integers,Strings or tuples are passed to a functions , the passing acts like pass-by-call. In other words, callee(被调用者) functions can not change value of that kind of arguments passed by caller(调用者) ones. While situation is different when mutable type ones like list or dict are passed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值