Python3 interpreter
On Linux / Unix systems, general default python version 2.x, we can python3.x installed in / usr / local / python3 directory.
After installation is complete, we can set the path / usr / local / python3 / bin to your Linux / Unix operating system environment variables, so you can start Python3 by entering the following command shell terminal.
The PATH the PATH = $ $: / usr / local / python3 / bin / python3 # set the environment variable $ python3 - Version Python 3.4.0
Under Window System you can be set by the following command Python environment variables, suppose your Python installation in the C: \ Python34:
set path=%path%;C:\python34
First, interactive programming
We can enter the "Python" at the command prompt to start the Python interpreter:
$ python3
After executing the above command, the following window appears information:
$ 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 python prompt, and then press Enter to view operating results:
print ("Hello, Python!");
The above command execution results are as follows:
Hello, Python!
When you type a multi-line structure, continued line is a must. We can look at the following if statement:
Flag = >>> True >>> IF Flag: ... Print ( " Flag condition is True! " ) ... Flag condition is True!
Second, the script programming
The following code copied to hello.py file:
print ("Hello, Python!");
The following command to execute the script:
python3 hello.py
The output is:
Hello, Python!
In Linux / Unix system, you can add the following command at the top of the script to make Python scripts can be the same as SHELL script can be executed directly:
#! /usr/bin/env python3
Then modify the script permissions, so have execute permissions, the command is as follows:
$ chmod +x hello.py
Execute the following command:
./hello.py
The output is:
Hello, Python!