Python Primer One

Source: Internet
Author: User

Python type

Programming languages are mainly categorized from the following angles: compiled and interpreted, static and dynamic, strongly typed, and weakly typed.

Compile-and-interpret
    • Compiled: Before the execution of the program, there is a separate compilation process, translating the program into machine language, and later executing the program, there is no need to translate. In simple terms, it is a translation, in the implementation, such as C + + this type of language

    • Interpreted: translates the program into machine language at run time, so the speed is slower than the compiled language. Is the translation side execution, such as python/java/js/c# and other types of language.

Both types have the meaning of translation, but the order of translation is different, which results in different types of language execution speed, adapt to the environment is not the same. A compiled language executes faster than an interpreted language, but cannot be executed across platforms.

Static language and Dynamic language
    • Static languages: Languages that can be determined at compile-time variable data types, most static type languages require that data types must be declared before they are used, and some modern languages with type derivation capabilities may be able to partially mitigate this requirement.
    • Dynamic language: Determines the language of the data type at run time. A type declaration is not required before a variable is used, and the type of the variable is usually the type of the value being assigned.
Strongly typed and weakly typed languages
    • Strongly typed languages: Once the type of the variable is determined, the language cannot be converted. In fact, the so-called seemingly transformed, are through the intermediate variables to achieve, the original variable type must be unchanged.

    • Weakly typed languages: The type of a variable is determined by its application context. For example, the language directly supports strings and integers can be done directly with the + number. Of course, in strongly typed languages that support operator overloading, this can be done in the form of an external implementation, but this is a completely different connotation.

In general, Python is a strongly typed language.

The first Python program

Compiling execution in Python's interactive mode

>>> print (' Hello World ') Hello world>>>
Character encoding

When the Python interpreter loads the code in a. py file, it encodes the contents of the file. In Python3, the default is to support Chinese, and in the Python2 before the use of Chinese characters without character conversion, will be an error.

The first appearing ASCII (American Standard Code for Information Interchange, the American Standards Information Interchange Code) is a Latin alphabet based computer coding system that is mainly used to display modern English and other Western European languages. It can only represent a maximum of 255 symbols, so it is available in Chinese.

ASCII table included:

In order to solve the problem of Chinese coding, in 1980, the first character encoding GB2312 was designed, which included 7,445 characters, including 6,763 Chinese characters and 682 other symbols. The 1995 Chinese character extension specification GBK1.0 contains 21,886 symbols, which are divided into Chinese characters and graphic symbol areas. The 2000 GB18030 is the official national standard for replacing GBK1.0. The standard contains 27,484 Chinese characters, as well as Tibetan, Mongolian, Uyghur and other major minority characters. Now the PC must support GB18030.

Developed from 1990 onwards, the Unicode (Uniform Code, universal Code, single code) officially released in 1994 is an industry standard in the field of computer science, including character sets, coding schemes, etc. Unicode is created to address the limitations of traditional character encoding schemes, which set a uniform and unique binary encoding for each character in each language to meet the requirements of cross-platform, cross-language text conversion and processing.

The UTF-8 (8-bit Unicode Transformation Format), released in 1992, is a variable-length character encoding for Unicode, also known as the Universal Code. It is now standardized to RFC 3629. UTF-8 encodes Unicode characters in 1 to 4 bytes. The same page can be used to display Chinese simplified traditional and other languages (such as English, Japanese, Korean).

Python Primer One

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.