First, the history of Python
II, Python2 or 3
The blogger chose Python3.
Download Python www.python.org from official website
Windows installs python3.5, python2.7. You may need to adjust the path after installation.
"Right-click Computer"-"Properties"-"Advanced system Settings"-"Advanced"-"Environment variable"-"in the second content box to find the variable named path of a row, double-click"-"Python installation directory appended to the variable value, with; such as: the original value; C:\python27, remember that there's a semicolon in front
Third, the first code:
"Hello word", of course.
print "Hello word"
Iv. variables
Variable names can only be any combination of letters, numbers, or underscores
The first character of a variable name cannot be a number
The following keywords cannot be declared as variable names
[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']
Example:
Name = "Tom"
Five, the Code
Python3 has the perfect support for UTF-8, and all of the bloggers ' Python uses Utf8,
UTF8: Chinese characters 3bytes, English 1 bytes
Vi. notes
Three quotation marks enable multiple lines of comment. #单行注释
7, the first knowledge module
You can import third-party modules, custom modules, and so on using import.
View the Import module catalog
1 Import SYS 2 Print (Sys.path)
View Code
8. Input
Input,python2 in the Python3 raw_input
>>> username = input ("Your name:") your name:otcsnow>>> print (username) otcsnow
9: Conditional statement, loop statement
If...else, If...elif...else,
While
For
A = 3if a > 3: print ("big") Elif a<3: print ( "less") Else: print ("equal") while a <: print (" While Loop ", a) a + = 1for i in range (5,a,2): print (" To loop, ", i) equal (' While loop ', 3) (' While Loop ', 4) Oop ', 5) (' While Loop ', ' 6 ') (' While Loop ', ' 7 ') (' While Loop ', ' 8 ') (' When Loop ', ' 9 ') (' for Loops ', ' 5 ') (' For Loop, ', 7 ') (' For Loop, ', 9)
Thanks.
Python's Big God Growth path: the first learning record