One
Interactive mode
1 #python2 3Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)4 5[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux26 7Type" Help","Copyright","credits" or "License" forMore information.8 9>>>
As shown above:
where ">>>" is the python interactive command line here directly enter the code to get results
Cases:
Input 2 python operation results
1 >>>1+123 2
Print "This is python! "Prints the output string
Print ' This is python! ' is python! exit Python "exit ()">>> exit ()
Second, the text mode
The so-called text pattern is actually writing the code into a file and then executing it in Python.
To edit a file, enter the following code:
[[email protected]_server py]# vim py 2 print '
* (Every time you execute a script, it will knock Python to perform the feeling is much more simple, just specify the Python bin path in the file so that each execution will not have to hit Python) *
Of course first determine your python's bin path
View Python command path
which python/usr/bin/python
Python is specified in the file
[Email protected]_server py] # Vim Pytest # !/usr/bin/python Print ' This is python ' Print ' 100+200= ', 100+200 execution results [[email protected]_server py]# ./pytest is python100+200= 300
Three, two ways each have advantages and disadvantages
1. Interactive mode
Pros: Get results quickly
Cons: Exit does not save
For short Code testing
2. Text mode
Pros: Code can be saved
Cons: Inconvenient operation
For complex code programming
Python Basics "Second piece" Python operation mode