Python basics-introduction, python-Introduction

Source: Internet
Author: User

Python basics-introduction, python-Introduction
I. Python

    • Cpython
      Python official version, which is implemented in C language and most widely used. CPython converts the source file (py file) into a bytecode file (pyc file) and runs on a Python virtual machine.
    • Jyhton
      For Java Implementation of Python, Jython dynamically compiles Python code into Java bytecode and runs it on JVM.
    • IronPython
      IronPython compiles Python code into C # bytecode and runs it on the CLR. (Similar to Jython)
    • PyPy (special)
      Python implements Python, and then encodes Python bytecode into machine code.
    • RubyPython, Brython...
Ii. python Installation              Right-click the computer] - - "[Attribute] - - "[Advanced system settings] - - "[Advanced] - - "[Environment variable] - -

[In the second content box, find a line with the variable name Path and double-click it]--> [Append the Python installation directory to the variable value, and use; Separate]

          For example: the original value; C: \ python27; remember that there is a semicolon before  

2. Installation of Linux

Direct yum install python

3. Basic Python knowledge4. Interpreter:

When running python D: \ python_test \ hello. py in the previous step, it is clearly pointed out that the hello. py script is executed by the python interpreter. Python File Execution Process

 

In linux, if you want to execute a python script like a shell script, for example:./hello.py In the header of the hello. py file, specify the interpreter as follows:

#!/usr/bin/env pythonprint('hello world')

 

5. character encoding

1. ASCII (American Standard, who made it invented)

Python 2. the X interpreter is loading. in The py file, the content is encoded (ascill by default). ASCII (American Standard Code for Information Interchange, American Standard Information Exchange Code) is a computer coding system based on Latin letters, it is mainly used to display modern English and other Western European languages. It can only be expressed in 8 bits (one byte) at most, that is, 2x8 = 256. Therefore, an ASCII code can contain up to 256 characters. For English and Western Europe, there are more than enough characters. Who makes English only 26 letters

2. Unicode (Uniform Code, universal code, and single code) is a character encoding used on computers. What if the Code contains Chinese, Japanese, and Korean ~~~~ (ASCII) Unicode is generated to address the limitations of traditional character encoding schemes. It sets a uniform and unique binary encoding for each character in each language, it is specified that some characters and symbols are represented by at least 16 bits (2 bytes), that is, 2*16 = 65536,
Note: here we will talk about at least two bytes, maybe more, and three or four Chinese characters. In this way, all of us are happy and can express ~~~~, But there are some flaws...

3. UTF-8 is the compression and optimization of Unicode encoding, which no longer uses at least 2 bytes, but classifies all characters and symbols: the content in the ascii code is saved in 1 byte, the European characters are saved in 2 bytes, and the East Asian characters are saved in 3 bytes... this not only reduces the amount of stored code, but also applies to multi-country languages (O (∩ _ ∩) O hahaha ~)

4. python 2.x is ASCII by default, and Python 3.x is UTF-8 by default

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.