Coding
Python source files are Unicode encoded with UTF-8 encoded strings
# -*-coding:cp-1252-*- Designated source file encoding method
Identifier
Use alphanumeric underlines
The first character is uppercase or lowercase letters or underscores
Case sensitive
Reserved words
>>>Importkeyword>>>keyword.kwlist['False','None','True',' and',' as','assert',' Break','class','Continue','def','del','elif','Else','except','finally',' for',' from','Global','if','Import','inch',' is','Lambda','nonlocal',' not','or','Pass','Raise','return','Try',' while',' with','yield']
Comments
Single-line Comment: #开头
Multiline comment: "' or" "
# Notes " " Comment Comment " " """ Comment Comment """
Indent in
indenting represents a block of code without using {} differs from other languages
The number of spaces to indent is variable but the same code block must be indented the same number of spaces
Multi-line statements
# using backslashes \ To implement multiple lines S = 1 + 2 + \ 3# The multiline statement in [], {}, or () does not need to use a backslash (\)Y = [' C15>s'Y', ' Z ']
Python basic syntax