Home > Article > Backend Development > Detailed explanation of function passing by value and reference in python
In python, functions such as integers, strings, and tuples are all passed by value. Their values will not be changed in the function. Others will change their values in the function.
For example, passing a list:
#-*-ecoding:UTF-8 -*- def fun(a): a[0]="sss"; print a print id(a) return ; a=["a","b"]; fun(a); print a; print id(a)
The value in the list has changed, but the address of the list has not changed
The above is the detailed content of Detailed explanation of function passing by value and reference in python. For more information, please follow other related articles on the PHP Chinese website!