1.1. Interactive interpreter
In the Linux command line, simply enter the python into interactive interpreter,
Above Python 2.7.5 represents the Python version 2.7 version,
"& gt;> & gt;" Said has entered the interaction of the python interpreter, input and print "hello world!" To show results,
Note:
Because python code using indentation expression logic, so we will strictly follow the indentation rules, usually use four Spaces;
Top-level code before there can be no Spaces;
The exit (), the quit () or CTRL - exit D interactive interpreter;
1.2. The script file
In a Linux system using vi or vim can text editing,
Method one: vim mytest. Py edit a called mytest. Py files (suffix must be py), content of the code is as follows:
Print 'hello world! '
Run the code:
Python mytest. Py # indicates that in python to perform mytest. Py
The result shows: the
hello world!
Method 2: vim mytest. Py to edit, the content of the code is as follows:
#! The/usr/bin/env python
Print 'hello world! '
Note: the first line (fixed format in Linux) show that the code to explain in python,
In some cases, python is not installed under/usr/bin, but env under/usr/bin, the need for env to try to find the installation position of python, ensure that you can find the python interpreter,
For code and execute permissions:
Chmod + x a mytest. Py
Run the code:
./mytest. Py
The result shows: the
hello world!
1.3. Pycharm
Set the font size: File - & gt; Settings - & gt; Editor - & gt; Colors & amp; Fonts - & gt; The Font - & gt; Save As -- & gt; Modify the Size
Run: Run in the menu bar - & gt; The Run - & gt; Choose to run the code
2. TAB auto-completion
2.1. Explain the Settings
> The import readline
> The import rlcompleter
> Readline. Parse_and_bind (' TAB: complete ')
> P
Pass pow (print print (property (
> Print the
Note: can only be used once, once out, immediately failure!
The import module
Edit TAB. Py files
Vim/usr/lib/python2.7/site - packages/TAB. Py
The import readline
The import rlcompleter
Readline. Parse_and_bind (' TAB: complete ')
Then the import TAB in the interactive interpreter module,
Each entry in the interactive python interpreter will need to repeat this action!
Set the environment variable
Automatic support TAB completion:
Vim/usr/local/bin/TAB. Py
The import readline
The import rlcompleter
Readline. Parse_and_bind (' TAB: complete ')
Vim ~/. Following
PYTHONSTARTUP=/usr/local/bin/TAB. Py
The export PATH PYTHONSTARTUP
The source ~/. Following
Note: the environment variable is PYTHONSTARTUP python runtime to execute script
Summary of Python
Python is a cross-platform programming language, the application is very extensive
Environment for
1, the operating system choice (Linux)
2, PIP package management (to solve the problem of the dependent on the install python package)
3, configuration pycharm (increase development efficiency)