Linux is generally loaded with Python, but the version does not have to be viewed by itself, and if the version is too low, it needs to be re-installed. Look at the Python version method and enter Python directly at the command line, which will go to the Python command line and display the Python version.
How to exit the Python command line, enter exit ()
Sometimes we need to see where Python is installed to install third-party libraries, and Linux can enter Python cmd first, then enter
Import Sys
Print Sys.path To print all Python paths. How to run a well-written Python script in Linux:There are two ways of doing this:
1. Execute directly using Python xxxx.py. Where python can be written as the absolute path to Python. Query using which python (on my CentOS, the query result for the which Python command is/usr/bin/python).
2, in the head of the file (first line) write #!/usr/bin/python2.7, this place uses the absolute path of Python, is the above with which Python query results. Then you can use it outside./xxx.py executed.
Because in Linux, Python shell These programs are normal text format, need a program to explain to execute it. Either call the time specified (mode 1), or specify in the file header (mode 2).
Linux and Python