In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use the python identifier, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
1. The identifier consists of characters, underscores, and numbers, but the first character cannot be a number.
2. Reserved characters cannot be the same as identifiers.
3. Cannot contain special characters such as spaces, @,%, and $.
4. Letters are strictly case sensitive.
Although identifiers can be underlined, identifiers that begin with underscores often have special meanings, so it is not recommended to use identifiers that begin with underscores unless you really want to do so.
Example
For example, the following identification conforms to the law:
Abcd
Abc_d
Abc_3d
IF / / python is case-sensitive, so if is a reserved word, but IF is not, you can use the
The following identifiers are illegal:
3abc / / numbers cannot begin
If / / identifiers cannot be the same as reserved words
@ abc / / identifiers cannot have special characters such as spaces, @,%, and $
Expansion of knowledge points:
Naming specification for Python identifiers
To put it simply, an identifier is a name, as if each of us has our own name, and its main function is to serve as the name of variables, functions, classes, modules, and other objects.
The naming of identifiers in Python is not random, but must follow certain command rules, such as marble platform factory.
Identifiers are made up of characters (AbeliZ and axiz), underscores, and numbers, but the first character cannot be a number.
The identifier cannot be the same as the reserved word in Python. Reserved words are described in more detail in subsequent chapters.
Identifiers in Python cannot contain special characters such as spaces, @,%, and $.
For example, the identifiers listed below are valid:
UserID
Name
Mode12
User_age
The following named identifiers are invalid:
4word # cannot start with a number
Try # try is a reserved word and cannot be used as an identifier
$money # cannot contain special characters
In Python, the letters in identifiers are strictly case-sensitive, that is, if the size and format of two identical words are different, the meanings of multiple representations are completely different. For example, the following three variables are completely independent and unrelated, and they are independent of each other.
Number = 0
Number = 0
NUMBER = 0
In the Python language, identifiers that begin with an underscore have a special meaning, for example:
Identifiers that begin with a single underscore, such as _ width, represent class attributes that cannot be accessed directly and cannot be imported through from...import*
Identifiers that begin with a double underscore, such as _ _ add, represent private members of the class
Identifiers that begin and end with a double underscore, such as _ _ init__, are dedicated identifiers.
Therefore, you should avoid using identifiers that begin with an underscore unless required by a particular scenario.
Thank you for reading this article carefully. I hope the article "how to use python identifiers" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.