Python Tutorial
Python Variable
Python Operators
Python Sequence
Python String
Python Flow Control
Python Functions
Python Class and Object
Python Class Members (properties and methods)
Python Exception Handling
Python Modules
Python File Operations (I/O)
python
command to detect whether Python is installed and which version is installed, as shown below:
[www.iditect.com@localhost ~]$ python Python 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>It can be seen that the
python
command can run normally and output the version information of Python, which indicates that the current Linux distribution already comes with Python 2.7.5. >>>
appears at the end of the execution result , which means that we have entered the Python interactive programming environment, where we can directly enter the code and view the running results, as shown below:
[www.iditect.com@localhost ~]$ python Python 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print("iditect URL is: http://www.iditect.com") iditect URL is: http://www.iditect.com >>> a=100 >>> b=4 >>> a*b 400 >>> exit() [www.iditect.com@localhost ~]$exit() is used to exit the Python programming environment and return to the Linux command line.
python3
command in Terminal, as shown below:[www.iditect.com@localhost ~]$ Python3 Python 3.6.4 (default , Nov 18 2018 , 13:02:36) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>If the
python3
command runs successfully and the Python prompt >>>
appears , it means that the current Linux distribution has installed the Python 3 development environment. Just execute the python3
command to start the Python 3 development environment. $ sudo apt-get update $ sudo apt-get install python3.8Explanation of the command:
python3
command
in the terminal again , and you can see that the Python interactive programming environment has been updated to Python 3.10.
.tgz
format. $ wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgzUnzip the source package:
$ tar -zxvf Python-3.10.2.tgz
$ ./configure --prefix=/usr/local $ make && sudo make installHere
--prefix=/usr/local
is used to specify the installation directory. If not specified, the default installation directory will be used. python
command invokes the Python 2.x development environment by default. If you are accustomed to using Python 3.x and feel that it is a bit troublesome to enter the python3
command every time, you can modify the configuration so that the python
command calls the Python 3.x development environment instead. The specific commands are as follows:$ sudo unlink /usr/bin/python $ sudo ln -s /usr/bin/python3.10/usr/bin/pythonNote that the path and version of Python 3.x in the second command must be correct.
python
command in the terminal again, and enter the interactive development environment of Python 3.10.