Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to resolve Python variable naming rules and define variables

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to parse Python variable naming rules and define variables, the content is very detailed, interested friends can refer to, hope to be helpful to you.

First, define variables

Grammar rules:

Variable name = value

The'='in the middle of the syntax rules that define variables does not mean an equal sign in mathematics, but rather an assignment in a programming language. Assignment: in fact, when the program is executed, it first calculates the value to the right of the equal sign ('='), and then assigns the value on the right to the variable name to the left of the equal sign.

Note: variable names are customized to meet the naming rules for identifiers.

II. Rules for defining variables

Identifier:

Variable naming convention-identifier naming convention is a unified specification for defining various names in Python. The specific specifications are as follows:

1. Consists of numbers, letters, and underscores

two。 Cannot start with a number

3. Python built-in keywords cannot be used

4. Strictly case-sensitive

The following is a list of common keywords, these keywords do not need to memorize, in the process of learning Python will naturally remember, do not use will not make mistakes

None True False and as break class continue def del elif else assert except finally for from if import in is lambda not or pass raise return try shile with.

Naming habits:

1. See the name and know the meaning

two。 Big hump: that is, the first letter of each word is capitalized, for example: UserName

3. Small hump: the first letter of the word after the second word is capitalized, e. G. userName

4. Underscore: for example: user_name

Such as:

UserName =''on how to parse Python variable naming rules and define variables to share here, I hope the above can be of some help to you, can 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report