Python Learning Note (ii) Two ways of implementing the first Python program

Source: Internet
Author: User

In interactive mode:

If you want Python to print out the specified text, you can use a print statement, and then enclose the text you want to print in single or double quotes, but you can't mix single and double quotation marks:

>>> print ' Hello,world '
Hello,world
In interactive mode, although convenient, but the execution of the code can not be saved, next we use a text editor to write and can be saved.

Open notepad++, choose the code you've edited, Python

# hello.py
print ' Hello World '

The last file name is hello.py, open the command line CD to the file's save path and enter the Python hello.py.

The result is:

Python hello.py
Hello World
Note:

1. #是python的注释部分类似c语言的//, the text python after it is not executed.

2. If the output kanji, must be converted to Unicode encoding, the format of print U ' Hello '

3. Check if your path is correct when you are prompted to do not have a file

Python Learning Note (ii) Two ways of implementing the first 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.