In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the basic grammars that must be learned by Python3". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The design of Python is highly readable. Compared with other languages, it often uses English keywords and some punctuation marks. It has more distinctive grammatical structures than other languages.
Coding
By default, Python 3 source files are encoded in UTF-8, and all strings are unicode strings. Of course, you can also specify different encodings for the source files:
#-*-coding: cp-1252-*-
The above definition allows the use of character encodings in the Windows-1252 character set in the source file, and the corresponding languages are Bulgarian, Blanc, Macedonian, Russian, and Serbian.
Identifier
The first character must be a letter in the alphabet or an underscore _.
The rest of the identifier consists of letters, numbers, and underscores.
Identifiers are case sensitive.
In Python 3, you can use Chinese as the variable name, and non-ASCII identifiers are also allowed.
Python reserved word
Reserved words are keywords, and we cannot use them as any identifier name. Python's standard library provides a keyword module that outputs all keywords for the current version:
> import keyword
> keyword.kwlist
['False',' None', 'True',' and', 'as',' assert', 'break',' class', 'continue',' def', 'del',' elif', 'else',' finally', 'for',' from', 'global',' if', 'import',' in', 'is',' lambda', 'nonlocal',' not', 'or' 'pass', 'raise',' return', 'try',' while', 'with',' yield']
Annotation
Single-line comments in Python begin with #. Examples are as follows:
Instance (Python 3.0 +)
#! / usr/bin/python3
# first comment
Print ("Hello, Python!") # second comment
Execute the above code, and the output is as follows:
Hello, Python!
Multiple # signs can be used for multiline comments, as well as''and'':
Instance (Python 3.0 +)
#! / usr/bin/python3
# first comment
# second comment
''
The third note
''
The fourth note
"
The fifth note
The sixth note
"
Print ("Hello, Python!")
Execute the above code, and the output is as follows:
Hello, Python!
This is the end of the content of "what are the basic grammars that Python3 must learn". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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
ErrorCould not find suitable statistics field with ID 'customfield_10002'. Solution:
© 2024 shulou.com SLNews company. All rights reserved.