Home >Backend Development >Python Tutorial >Is name an identifier of Python?

Is name an identifier of Python?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-25 10:08:205243browse

Is name an identifier of Python?

Is name an identifier for python? Let me give you a detailed introduction:

Identifier

What is an identifier? See the picture below:

Is name an identifier of Python?

Some symbols and names customized by developers in the program.

Identifiers are defined by yourself, such as variable names, function names, etc.

Rules for identifiers

Identifiers consist of letters, underscores and numbers, and numbers cannot begin.

Related recommendations: "Python Video Tutorial"

Thinking: Which of the following identifiers are correct, and which ones are incorrect? Why?

  fromNo12
   from#12
   my_Boolean
   my-Boolean
   Obj2
   2ndObj
   myInt
   test1
   Mike2jack
   My_tExt
   _test
   test!32
   haha(da)tt
   int
   jack_rose
   jack&rose
   GUI
   G.U.I
python中的标识符是区分大小写的
num3=40;
Num3=50;
print(num3);
print(Num3);
输出:
40
50

Naming rules

Know the meaning after seeing the name

Choose a meaningful name, and try to know it at a glance. What does it mean (to improve code readability) For example: the name is defined as name, and student is defined as student.

Camel case nomenclature

Is name an identifier of Python?

Lower camel case nomenclature (lower camel case): The first word starts with a lowercase letter; the first word of the second word Capital letters, for example: myName, aDog

Upper camel case (upper camel case): The first letter of each word is capitalized, for example: FirstName, LastName

But in the program There is also a popular nomenclature among members, which is to use underscore "_" to connect all words, such as send_buf

The above is the detailed content of Is name an identifier of Python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn