Python Learning Summary (i), the first Python program is written

Source: Internet
Author: User

1. Python is a high-level programming language for explanatory, compiled, interactive languages, object-oriented, dynamic data types.

1.1 Interactive: means that you can directly interact with the program you write at a prompt.

1.2 Explanatory: This means that there is no compilation of this link during the development process.

1.3 Object-oriented: it means that it supports object-oriented styles, or code encapsulation in object programming techniques.

2. Python complies with the GPL (GNU general public License) agreement.

3. Features of Python

Relatively few keywords, simple structure has a well-defined syntax, code definition is clear, easy to maintain, has a rich library, cross-platform in the system compatibility is good based on open source features, can be ported to many platforms, can call C or C + + part of the code, it also provides interfaces to all major business databases. You can create and migrate to many system calls.

4. Construction of the environment

Python download: Go to the python website https://www.python.org/download

Python Document: https://www.python.org/doc/

5. Installation of Python

such as Baidu experience

6. Environment variable Configuration

Configure the Python installation directory in My Computer--Properties--Advanced environment variable--path.

Or, in the command prompt (cmd), enter

path=%path%;  C:\python,C:\python for its installation directory, and then press Ebter  

7. Chinese encoding

We can use Python to enter English, but when we need to input Chinese, there may be garbled or error cases.

Because Python's default encoding format is Asc| |, it is not possible to print Chinese characters without modifying the encoding format, so the error will be

Workaround: You can add #-*-coding:utf-8-*-or #coding =utf-8 at the beginning of the file .

Note: #coding =utf-8 = no spaces on either side.

The first code of the program is as follows:

#!/usr/bin/python
#-*-Coding:utf-8-*-
Print "Ni hahaha";

Note: python3.x source files use utf-8 encoding by default, so you can parse Chinese normally without specifying UTF-8 encoding.

Note: If you use the editor and you need to set the PY file storage format to UTF-8, you will receive an error message similar to the following:

To modify a step:

File-setting-file encodings, you'll understand.

Python Learning Summary (i), the first Python program is written

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.