Annotation prefix #
# ! /Usr/bin/Python
# Filename: helloworld. py
Print ' Hello python. '
String
1. 'is the same"
2. ''' is used to define multi-line strings and can be used freely. 'And"
>>> Print ''' This is a multi-line string. This is 1st line.
This is Second line.
"What's ur name? ", I asked.
"My name is fourth line! ". '''
This Is A Multi - Line string. This Is 1st line.
This Is Second line.
" What's ur name? " , I asked.
" My name is fourth line! " .
>>>
3. Escape Character \
4. Natural string prefix, R or R
Natural string: a string that does not recognize escape characters.
5. Unicode string prefix, U or U
6. The string that is put together will automatically Cascade
7. Separate output content, similar to cascade, but a space is automatically added
>>> Print ' This is ' " A sentence. "
This isa sentence.
>>> Print ' This is ' , " A sentence. "
ThisIsA sentence.
Separate statements
Or the end of a physical row to indicate the end of a statement.
However, the semicolon is usually not seen in Py;
I = 5
Print I
I= 5;PrintI
I= 5;PrintI;
I= 5;
PrintI;
ProgramBlock Division
Use indentation to represent the program hierarchy
RecommendedSingle TabOrTwo or four spaces
Operator
1. **, power, X ** y, returns the Y Power of X.
2. //, division. Returns the integer part of the operator.
3 .~, Flip by bit ,~ X returns-(x + 1 ),~ 5.
4. Not, And, Or, logical operators.