1 , python Kinds and Differences
Cpython
The official version of Python, implemented using the C language, is the most widely used, and the CPython implementation converts the source file (py file) into a bytecode file (PYc file) and then runs on the Python virtual machine.
Jyhton
Python Java implementation, Jython will dynamically compile Python code into Java bytecode, and then run on the JVM.
IronPython
In Python's C # implementation, IronPython compiles Python code into C # bytecode and then runs on the CLR. (similar to Jython)
PyPy (Special)
Python implements Python, which compiles Python bytecode bytecode into machine code. Rubypython, Brython ...
2 , python Environment Construction ( Windows platform)
2.1 installation python (in py27 installation As an example, py35 installation is substantially the same)
A. Download python, visit https://www.python.org/downloads/
Note System version (32bit/64bit)
B. Install Python
C. Define the installation location
D. Installation Complete
2.2 Configuring environment Variables
A. Editing environment variables
B. Adding parameters
C. Results (We want)
2.3 Python Development Tools ( Pycharm ) Installation
A. Download windows version pycharm
Address: http://www.jetbrains.com/pycharm/download/#section =windows
B. Install Pycharm, direct next, until end of installation
C. Opening pycharm for the first time (open pycharm after installation is complete)
D. Prompt to activate Pycharm
E. Find the activation code, visit: http://idea.lanyus.com/
F. Enter the activation code
G.pycharm initialization Configuration
H. Defining the project location and the PY version in Pycharm
I. Final note
3 , python Environment Construction ( Linux platform)
3.1 Linux the platform is commonly used Centos and the Ubuntu
The A.linux platform recommends the use of Ubuntu systems, which are already available with the PY27 and py35 versions, without any additional manual installation
B.centos, copy Teacher's configuration steps
4 , Primary knowledge python
4.1 first one python Code
>>> print "Hello World"
Hello World
Or execute a PY file
F:\pycharm\python>python py_learn/day1/first.py
Hello World
4.2 python Interpreter and Code
A. When the Python interpreter loads the code in the. py file, the default Py2 version encodes the content in "ascill" mode, py3 version, which uses the "Unicode" encoding by default, and we do not need to consider the Chinese garbled problem
B. Since Ascill encoding, we can write in Chinese is garbled (only for py27), so when we write Python code, we first declare the Code encoding type
C. In addition to defining the encoding type, since our code may be running in Linux, we also specify the python interpreter
#!/bin/env python first line specifies interpreter
#-*-Coding:utf-8-*-The second line specifies the encoding type
4.3 Notes
Single-line Comment: # Annotated content
Multi-line Comment: ' annotated content '
4.4 PYc file
When you execute Python code, if you import a different. py file, a. pyc file with the same name is automatically generated during execution, which is the bytecode generated after the Python interpreter was compiled. The PYc file is generated for the next time the py file is executed, the interpreter reads the contents of the pyc file directly, saves the compilation time and improves performance
PS: Code is compiled to generate bytecode, and bytecode can be obtained by decompile.
4.5 python variables
A. Variable naming conventions
* The first character must be a letter in the alphabet (uppercase or lowercase) or an underscore ('_')
* Other parts may consist of letters (uppercase or lowercase), underscore ('_') or numerals (0-9)
* Variable names are case sensitive
* cannot be named as a keyword
B. Variable naming
name = ' Shaw '
C. Repeat variables
#!/bin/env python
#-*-Coding:utf-8-*-
name1 = ' Shaw '
name2 = ' Sam '
Name2 = name1
Print name2 name2 finally "Shaw"
4.6 python input
Python2 input with "raw_input ()", Python3 input with "input ()"
#!/bin/env python
#-*-Coding:utf-8-*-
Name = Raw_input (' Enter your Name: ')
Password = input (' Enter your password: ') The password entered here is " plaintext "
Print Name,password
Second Edition
Import Getpass
Name = Raw_input (' Enter your Name: ')
Password = getpass.getpass (' Enter your password: ') The password entered here is " ciphertext "
Print Name,password
4.7 Process Control
A. Basic process
For I in range (1,100):
If I% 2 = = 1: Condition established
s + = I execute this code
else: otherwise (i.e. "the above conditions are not valid")
Y + = I executes this code
Print S-y
B. Complex processes
Name = raw_input (' Please input your name: ')
If name = = ' Shaw ': condition 1 established
print "Hello Handsome!" "The implementation of this paragraph
elif name = = ' Stiven ': Condition 2 established
print ' You're OK ' to perform this section
elif name = = ' Sam ': Condition 3 established
Print ' Why are you so sad ... ' To perform this section
Else: The above conditions are not valid
print ' Ay ... ' To perform this section
4.8 while Loops
A. Basic cycle
While condition:
Loop body If the condition is true, then the loop body executes, otherwise the loop body does not perform
B. Continue (exit the current loop and continue the next cycle)
C. Break (exiting the current loop)
4.9 python Indent in
A. Python code block, which is distinguished by "indentation".
B. Python all code remains indented uniformly ( two or four cells )
Python Full stack development day1