In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what are the four ways of citing and transmitting parameters in Python. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Reference pass Ref 1: > a = 100# where an is an immutable type > def test (a):. The expression a+=a# has two meanings: 1. This may be a redefinition of a new variable aPermine 2. It is also possible to modify the value of a, but since the global # variable a cannot be modified, an an is redefined here. Print ("within function:% d"% a). > test (a) function: 200 > print (a) 100Ref 2: > a = [100] # where an is a list and is a variable type > def test (a):. Since list an is a mutable type, here is to modify a... Print ("within function:"). Within the print (a)... > > test (a) function: [100,100] > > print (a) [100,100] reference 3: > > a = 100,100 > > def test (a):. At first, a=a+a # is easy to understand, so it can be considered as equivalent to a=a+a, so it is the same as the reference. Print ("within function:% d"% a). > test (a) function: 200 > print (a) 100Ref 4: > a = [100A] > def test (a): # 1. Count the # 2 to the right of the = sign first. The result is [100100] # 3. A = [100100] # 4. Let the a variable point to [100100], that is, a holds a reference to [100100] (memory address). A=a+a # in this case, the a to the left of the equal sign is a redefined quantity, in which case a=a+an is not the same as a quantity. Print ("within function:"). Print (a)... > test (a) function: [100,100] > > print (a) [100] on what the four ways of passing parameters in Python are shared here, I hope the above content can be of some help to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.