Author: vamei Source: http://www.cnblogs.com/vamei welcome reprint, please also keep this statement. Thank you!
Simple 'Hello world! '
1. Run Python directly
If you have installed python, enter the following command in the Linux Command Line:
$ Python
Directly go to Python. ThenCommand Line prompt >>>Enter the following information:
>>> Print 'Hello world! '
As you can see, Python then outputs on the screen:
Hello world!
PrintIs a commonly used Python keyword (keyword). Its function is output.
(In Python 3. X, the print syntax will be changed and used as a function. Therefore, the above should be writtenPrint ('Hello world! '), And so on)
2. Write a small segmentProgram
Another method that uses python is to use a text editor.Write a file ending with. pyFor exampleHello. py
InHello. pyAnd save:
Print 'Hello world!'
Exit the text editor and enter:
$ Python hello. py
To run Hello. py. You can see the subsequent output of Python.
Hello world!
Summary:
Print
Command Line Mode: Run Python and enter the command in the command line and execute it.
Program mode: Write and run a python program.