The so-called interaction is interacting with the user that we use Python, you give instructions or code, and the Python interpreter gives the result. The call interpreter does not pass the script file as a parameter and displays the following prompt:
Python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on Darwin
Type "Help", "copyright", "credits" or "license" for more information.
>>
Type the following text at the Python prompt, and then press ENTER:
>> print "Hello, python!" #python2.0
>> print ("Hello, python!") #python3.0
Hello, python!.
It is highly recommended to use Ipython, which is installed in the following ways: http://blog.51cto.com/fklinux/2046741
Script Mode Programming:
So-called scripting, which is to write Python instructions or code into a text file, and then specify a command interpreter for these instructions, this file is a Python script.
For example: write the following code in a test.py file
Print "Hello, python!"
To run the program:
Python test.py
Hello, python!.
Another way to execute a python script, modify the test.py file:
#!/usr/bin/python
Print "Hello, python!"
To run the program:
chmod +x test.py
#./test.py
Hello, python!.
Using Chinese in script mode programming
Python uses ASCII code by default, does not support Chinese, the Chinese language needs to be declared to support the Chinese character set, generally utf8, the way is as follows:
#!/usr/bin/python
#coding =utf8
#encoding: Utf-8
#* coding:utf-8 *
print "Hello China!" "
Why are there so many ways to write all 3 of them? Python is a regular way to detect that your character set definition has something he wants to see, as long as it matches the following:
coding[:=]\s* ([-\w.] +)
[email protected] python]# cat a.py
#!/usr/bin/env python
#fdsf Coding=utf8 Fdaf like here fdsf Fdaf is I casually write, as long as there are coding utf8 and so on can
Print "Hello China"
Note: Chinese is already available directly in Python3 and does not need to specifically specify a character set that supports Chinese
Cloud computing Python automation Operations Development: Interactive mode programming