Variable, buffer value, encoding, Variable Buffer value Encoding
Variable, buffer value, encoding
-- Daoxin
Variable
Declare Variables
Eg:
#! /Usr/bin/env python
#-*-Coding: UTF-8 -*-
Name = "DaoXin"
The code above declares a variable named: name. The value of the variable name is: "DaoXin"
The role of a variable: nickname, which represents the content stored in an address in the memory.
Rule for variable definition:
- Variable names can only be any combination of letters, numbers, or underscores
- The first character of the variable name cannot be a number.
- The following keywords cannot be declared as variable names
['And', 'as', 'assert ', 'Break', 'class', 'contine', 'def', 'del ', 'elif ', 'else', 'Got t', 'exec ', 'Finally', 'for ', 'from', 'global', 'if', 'import', 'in ', 'Is ', 'lambda', 'not ',' or ', 'pass', 'print', 'raise ', 'Return', 'try', 'while ', 'with', 'yield ']
C language, no string, only characters, Arrays
Hello --- five characters
Use a character array to forge string character arrays ['h', 'E', 'l', 'l', 'O']
Character string feature. Once modified, re-create
Buffer
Buffer value in python
Eg:
Define two variables i1 and i2
>>> I1 = 100
>>> I2 = 100
Input: id (i1), id (i2)
Output: (1501868224,150 1868133)
Assign another value
>>> I1 = 1
>>> I2 = 1
Input: id (i1), id (i2)
Output: (1501865056,150 18.056)
String, With a buffer value, within a certain range, the id is the same, beyond the range, different, number buffer value-5 to 257
Python File Execution steps
Load memory> lexical analysis> syntax analysis> compile> bytecode> execute bytecode> machine code> execute machine code
Encoding
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, 2 ** 8 = 256. Therefore, the ASCII code can only represent 256 symbols at most.
Unicode
Unicode (unified code, universal code, Single Code) is a character encoding used on a computer. 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
UTF-8
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...