An explanatory object-oriented language.
Strong type. Although it is declared for changes, once a variable has a value, it also has a type. To assign other values, you must use type conversion.
All objects, classes, functions, and modules are objects.
No Boolean, none, 0, "", [], {}, () are false.
List (list, defined as []), which is equivalent to a vector in C ++ or an array in C. Its subscript starts with 0, and negative numbers can be used.
A string consisting of single or double quotation marks. A long string can be defined together with three consecutive double quotes, exceeding multiple rows. The string can be considered as a list of many characters.
Tuple is a constant list, represented by (). The brackets are omitted. The tuples can return elements or sub-tuple by subscript. The tuples can be used to assign values to multiple variables, such as, B = (1, 2 ).
Sequence includes string, list, And tuple. They have some common operations: Using in to determine whether an element is in the sequence: If X in
Seq. Obtain the length of the sequence Len (SEQ ). Use subscript to retrieve element SQL [I] And subseq: SQL [start: end] By subscript with colon, and use + to connect
Input two seq, and use * to represent repeated seq.
A dictionary is an unordered structure. Each element is a pair, including value and key. The key type is integer or
The string and value types are arbitrary. The dictionary does not contain duplicate keys. Each element in the dictionary is a tuple, which includes
Elements, keys, and values are called pair. In pair, values are followed by keys. You can use d [Key] to obtain the value. The dictionary is enclosed.
Conditional statement if:
If <expr1 >:< one-line-Statement>
Or
if <expr1>:
<statement-block>
Or
if <expr1>:
<statement-block>
else:
<statement-block>
Or
if <expr1>:
<statement-block>
elif <expr2>:
<statement-block>
elif <expr3>:
<statement-block>
...
else:
<statement-block>