In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the use of Python underlining, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Used in the Python interpreter to represent the result of the last execution
Even if you don't use Python for programming, you can use it as an intelligent calculator, and the underscore saves the results of the last calculation, which is quite convenient for calculation:
> 4 + 37 > > _ 7 > > _ + 29 > > a = 10 > _ 92, an independent underscore in the code indicates that this variable is not important
An independent underscore, it is also a variable name, but it is special, when you use an underscore as a variable name, it means you tell everyone that this variable is not important, only occupies a place, can be ignored, and will not be used later.
Of course, it's just a convention, and you can do it if you don't follow it. After all, you can get the value of this variable by underlining it later.
For I, _ in [(1,2), (3,4)]: print (I)
The above code indicates that we only need the first tuple in the list, and the second one is actually assigned to the underscore, although you can get the value later through the sliding line, but you are strongly advised not to do so, which is a violation of the convention.
3. The method of beginning and ending of double underscore is a magic method.
For example, the common'_ _ init__','_ _ dict__','_ _ dir__','_ _ doc__','_ eq__' and so on.
You can read how to write amazing Python classes.
4. as part of the middle of the variable name
Compared to hump naming, this is called serpentine naming, such as user_name.
5. As a part of the number, it is easier to read > 10000000 10000000 > 1" 28000050000000 = = 1280500000 True is all the content of this article "what is the use of Python underlining?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.