Python statement
Assignment statements
1. Assign the 3 object to the variable a
2, 3, 4 is assigned to the variable, a, b
1 >>> a = 3 2 >>> A, B = 3,43 >>> a4 35 >>> b6 47 >>> a = 3,48 >>> a9 (3, 4)
3, the realization will a,b=3,4 exchange a,b=4,3
1>>> b =3,4 Generally we declare a temporary variable to resolve2>>> temp =a3>>> A =b4>>> B =Temp5>>>a647>>>b839>>> b,a=This can be done in Python, because the variable has no type and the object has a typeTen>>>a One3 A>>>b -4 ->>>
4. First program Hello Word
Ⅰ Create a new py file helloword.py with the following
Print " Hellword "
Execute at command line (CMD)
1 g:\pythonworkspace>2 g:\pythonworkspace>python helloword.py3 Hellword
Ⅱ Four operator creates a new file study.py with the contents of
① The first behavior is used to specify the interpreter that executes the script, telling the computer that the program executes the name of the system variable
② second behavior encoding format set to UTF-8
③ third line three double or three single quotation marks for document comments
1 # !/ Usr/bin/env python 2 # coding:utf-8 3 4 Span style= "COLOR: #800000" "" "" 5 calculation 6 56+8*5-18/9 7 8 9 A = 8 * 5-18/9 # arithmetic
10
print a
1 g:\pythonworkspace>python study.py command line execution 2 94
Python Learning Notes (vi) Python first program