Identifiers in Python are case-sensitive.
Python can display multiple statements on the same line by separating them with semicolons;
Python code blocks do not use curly braces {} to control classes, functions, and other logical judgments. The most distinctive feature of python is to use indentation to write modules.
A group of statements with the same indentation constitutes a code block, which we call a code group.
Compound statements like if, while, def, and class start with a keyword and end with a colon ( : ) on the first line, and one or more lines of code after that line form a code group.
if expression :
suite
elif expression :
suite
else :
suiteSingle-line comments in python begin with #.
'''
Use three single quotes ( ) or three double quotes ( ) for multi-line comments in python"""
.Python can use quotation marks ( ' ), double quotation marks ( ” ), triple quotation marks ( '' or """ ) to denote strings, and quotation marks must start and end of the same type.
The default output of print is a newline. If you want to achieve no newline, you need to add a comma at the end of the variable, ,
In Python,
member variables starting with an underscore "single underscore" are called protected variables, which means that only the class object and subclass objects can access these variables;
"double underscore" starts with private members, which means that only the class object can access them. Even subclass objects cannot access this data.
Starting and ending with a double underscore ( foo ) represents the identifier dedicated to a special method in python, such as init () for the constructor of a class.Multi-line statements
Python statements generally use a new line as the terminator of the statement.
But we can use a slash ( \ ) to split a line of statements into multiple lines as follows:
total = item_one + \
item_two + \
item_three- Variable Types
Variable assignment in Python does not require a type declaration.
Python has five standard data types:
Numbers (number)
String (string)
List (list)
Tuple (tuple)
Dictionary (dictionary)
#这是第一个python脚本
'''
这是多行注释
这是多行注释,使用单引号
'''