Python basics 01 Hello world!

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.