Python Basics-Python Introduction

Source: Internet
Author: User

1. Introduction to Python

-Programmers reduce development costs

Entrepreneurial companies-Python uses more and develops efficiently

Established large companies-have departments to use

-Application areas

? automated operation and maintenance

--Install Linux to bring your own Python

--ready-made libraries, high development efficiency

? Automated testing

? Big Data analytics

? crawler

? Web


2. Python vs. Other languages

-C: Machine code

-Other high-level languages: bytecode-and machine-code

Go language specializes in dealing with network concurrency

3. Types of Python

-CPython: Machine code, C-byte code (one line)

-PyPy: Code, C-byte code, machine code (all finished and then executed, compile takes time)

-Other Python: code-and other bytecode--machine code (one line)

Just learn the Python rules when you learn

4. Python Basics

-Python Rules

? Install: Python interpreter

? Write program C:\python.exe test.py

A. Opening a file, reading the contents of a file

B. Lexical analysis, grammatical analysis

C. Byte code

D. Machine code

-Interpreter

Under Windows:
? C:\python.exe test.py

Under Linux:
Head Add Comment: #!/usr/bin/python (Linux automatically switches to the appropriate interpreter to interpret the script)

? Change executable permissions: chmod 755 test.py

? Execute code:./test.py

-Coding

English: ASCII

Universal code (at least 16 digits, Unicode): English 2 bytes, Chinese 3 bytes, 8 bit 1 bytes back row-> encoding

Utf-8: Compression of the Universal Code, English 1 bytes, Chinese 3 bytes

Chinese encoding Related:

gbk,gb2312

Utf-8:3 bytes, 24 bits

Gbk:2 bytes, 16 bits

Summarize:

    • Utf-8 general format; files stored in some encoding format should be read with corresponding codes, otherwise garbled

    • The beginning of the script--coding:utf-8--tells the interpreter to interpret it in utf-8 format (utf-8 when stored), which can be read normally

Python Encoding Related:

--File storage encoding

--Python interpreter encoding (Python3 default utf-8, to be interpreted in other ways, specify #--coding:utf-8--)

5. Pre-compiled byte code

. PYc after compiling the byte code

6. Variables

-Alphabet
-Number (Cannot start)
-Underline
-Cannot use Python built-in keywords

PS: Underline split

7. Input and output

v = input ("")import= Getpass.getpass (" Please enter the password:  ")print(PWD)

8. Conditional statements

Scene one if Xx:pass

Scenario Two if Xx:pass Else:pass

Scene three if Xx:pass elif xx:pass else:pass

9. Looping statements

While condition:

Continue # Start the Next loop now

Break # jump out of all loops

Python Basics-Python Introduction

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.