Basic python syntax and python syntax
By default, python is coded in UTF-8, and all strings are Unicode strings that can define different encodings for the code.
#coding:UTF-8#OR#-*- coding:UTF-8 -*-
Reserved Words and keywords, cannot be any identifier name. View All Keywords of the current version: keyword Module
1 import keyword # import keyword module 2 keyword. kwlist
['False', 'none', 'true', 'and', 'as', 'assert ', 'Break', 'class', 'contine ', 'def', 'del ', 'elif', 'else', 'partition t', 'Finally', 'for ', 'from', 'global', 'if ', 'import', 'in', 'is, 'La
Single line comment: in the code#The line at the beginning is a comment, and the program will not execute this line during execution
Multi-line comment: "multi-line comment" or '''multi-line comment''
# This is a comment ''', this is the second comment ''' "This is 3rd comments """
Python has data types: Boolean, integer, long, floating point, String, list, tuples, dictionaries, and dates.
In [4]: bool (True) Out [4]: TrueIn [5]: bool (False) Out [5]: FalseIn [6]: bool (0) out [6]: FalseIn [8]: bool ([]) # Empty list Out [8]: FalseIn [9]: bool (()) # Empty tuples Out [9]: FalseIn [10]: bool ({}) # empty dictionary Out [10]: FalseIn [12]: bool (1) Out [12]: true .................
# Type (): view the data type In [13]: type ("hello world") Out [13]: strIn [14]: type ("123 ") out [14]: str
Standard output. print () is a line feed by default. To avoid line feed, add end = ""
>>> Print ("hello world! ", End =" "," hello python! ") # Output without line breaks >>> hello world! Hello python!