Implementation of python3 interpreter


On linux/unix systems, the general default Python version is 2.x. we can install python3.x in /usr/local/python3 directory.

After installation, we can add the path /usr/local/python3/bin to the environment variable of your linux/unix operating system, so that you can start python3 by entering the following command through the shell terminal.

$path=$path:/usr/local/python3/bin/python3 \set environment variables
$ python3 --version
Python 3.4.0

In the window system, you can set Python environment variables through the following commands, assuming that your Python is installed under c:\python34:

set path=%path%;C:\python34

interactive programming

We can start the Python interpreter by entering the “Python” command at the command prompt:

$ python3

After executing the above command, the following window information appears:

$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.

Enter the following statement in the python prompt, and then press enter to check the running effect:

print ("Hello, Python!");

The execution results of the above commands are as follows:

Hello, Python!

When typing a multiline structure, a continuation line is required. We can see the following if statement:

>>> flag = True
>>> if flag :
... print ("flag condition is true!")
Flag condition is true!

Scripted programming

Copy the following code into the file:

print ("Hello, Python!");

Execute the script with the following command:


The output result is:

Hello, Python!

In linux/unix systems, you can add the following commands at the top of the script so that Python scripts can be executed directly like shell scripts:

#! /usr/bin/env python3

Then modify the script permission so that it has execution permission. The command is as follows:

$ chmod +x

Execute the following command:


The output result is:

Hello, Python!

This is the end of this article about the implementation of the python3 interpreter. For more relevant content of the python3 interpreter, please search the previous articles of developeppaer or continue to browse the relevant articles below. I hope you will support developeppaer in the future!

Recommended Today

JS generate guid method

JS generate guid method Globally unique identification(GUID) is an algorithm generatedBinaryCount Reg128 bitsNumber ofidentifier , GUID is mainly used in networks or systems with multiple nodes and computers. Ideally, any computational geometry computer cluster will not generate two identical guids, and the total number of guids is2^128In theory, it is difficult to make two […]