In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the annotations and specifications in python, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Some principles should be followed when naming. Usually, variables and constants refer to a certain thing or an attribute of something, so variable names and constant names are usually named by one or more nouns in English. The method (also known as function) refers to the execution of an action, so the name of the method (function) is usually named by English verbs or a combination of verbs and nouns. It is necessary to prepare English-Chinese bilingual dictionary software in advance when writing code. My English is not very good. I installed a Microsoft Bing Dictionary on my phone. I checked and memorized it while programming, forcing myself to form the habit of naming in English.
Constant
The letters are all capitalized and underlined to connect the words, such as:
HEIGHT = 300WINDOW_HEIGHT = 300
Note that constants are a common rule of python programmers in python. In essence, the python interpreter does not limit the modification of constants.
Instances of variables, functions, classes
All lowercase names, connected by underscores to each word, such as:
New_id = 1001old_id = 1new_id_list = []
Private attribute. The variable name begins with an underscore to indicate the private attribute.
_ salary = 6666 class name
The initials are capitalized in hump style, such as:
Class NewStudent (object): modules and packages
All in lowercase letters, connected by underscores
System preserves naming
_ _ xx__, such variables are system-reserved naming conventions, programmers write variables to avoid using this format.
Annotation
A single-line comment can be written on a separate line or at the end of a line of code.
A single-line comment begins with # followed by 2 spaces, followed by # followed by a space, and then writes a comment, for example:
_ salary = 6666 # Private attribute salary, which cannot be accessed publicly.
Multiline comments refer to the content between the beginning of three single quotation marks and the end of three single quotation marks, or the beginning of three pairs of quotation marks and the end of three pairs of quotes. You cannot start with three pairs of quotation marks or end with three pairs of quotation marks.
The most common situation for multiline comments is to annotate documentation for classes and functions, such as:
Def add_x_y (x, y): # the following multi-line comments, the beginning of''must pay attention to indentation, the end of a separate line can not pay attention to indentation. '' this is an adder. Enter two parameters and return the sum of these two parameters.''return x + yprint (add_x_y.__doc__) # _ doc__ is the documentation for viewing the method or class. You can also use help (add_x_y) to view class Student (object):' 'student class' 'passprint (Student.__doc__) out: this is an adder, enter 2 parameters Return these two parameters and the student category above are the annotated specifications in python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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.