day01

1. Introductory ceremony:

It is so simple to get started, I am proficient in Hellowrld in various languages

# is a single line comment

''' is a multi-line comment, ending with '''

Author name: Author: JamesStone

 

2. Variables

Variables are similar to java. Remember that the camel case nomenclature cannot declare the keyword $_ as a variable; first define a name as ximenjiji

Define another name2 equal to name, and then define another as Jamse, guess what is the final output result?

 

 The result is this, why?

 

The process is like this: name=ximenjiji, name2=name, which means that name is assigned to name2, then name2 = Ximen chicken, name=James

 

 

 3. Character encoding:

To handle Chinese characters, programmers designed GB2312 for Simplified Chinese and big5 for Traditional Chinese.

GB2312 (1980) contains a total of 7445 characters, including 6763 Chinese characters and 682 other symbols. The inner code range of the Chinese character area is from B0-F7 in the high byte and A1-FE in the low byte. The occupied code points are 72*94=6768. Among them, 5 vacancies are D7FA-D7FE.

GB2312 supports too few Chinese characters. The Chinese character extension specification GBK1.0 in 1995 included 21886 symbols, which are divided into Chinese character area and graphic symbol area. The Chinese character area includes 21003 characters. GB18030 in 2000 is the official national standard to replace GBK1.0. The standard includes 27,484 Chinese characters, as well as Tibetan, Mongolian, Uyghur and other major minority languages. The current PC platform must support GB18030, and there is no requirement for embedded products. Therefore, mobile phones and MP3s generally only support GB2312.

From ASCII, GB2312, GBK to GB18030, these encoding methods are backward compatible, that is, the same character always has the same encoding in these schemes, and later standards support more characters. Among these encodings, English and Chinese can be handled uniformly. The method to distinguish Chinese encoding is that the highest bit of the high byte is not 0. According to the programmer's name, GB2312, GBK to GB18030 belong to the double-byte character set (DBCS).

The default internal code of some Chinese Windows is still GBK, which can be upgraded to GB18030 through the GB18030 upgrade package. However, the characters added by GB18030 relative to GBK are difficult for ordinary people to use. Usually, we still use GBK to refer to the Chinese Windows internal code.

 Obviously, ASCII code cannot represent all kinds of characters and symbols in the world, so it is necessary to create a new encoding that can represent all characters and symbols, namely: Unicode

Unicode (Unicode, Universal Code, Unicode) is a character encoding used on computers. Unicode was created to solve the limitations of the traditional character encoding scheme. It sets a uniform and unique binary encoding for each character in each language, and stipulates that although some characters and symbols are represented by at least 16 bits (2 bytes), that is: 2 **16 = 65536,
Note: The minimum size is 2 bytes, maybe more

UTF-8 is the compression and optimization of Unicode encoding. It no longer uses at least 2 bytes, but classifies all characters and symbols: the content in ascii code is stored in 1 byte, European characters Save with 2 bytes, East Asian characters with 3 bytes...

Therefore, when the python interpreter loads the code in the .py file, it will encode the content (ascill by default), if it is the following code:

Error: ascii code cannot represent Chinese

Correction: It should be displayed to tell the python interpreter what encoding to use to execute the source code, ie:

 4. User Input

The user input is just an input(), which is very simple

 

When you want the password to be smaller and black dot to enter the password, if you want to be invisible, you need to use the getpass method in the getpass module, that is:

 

 

 

 

 

---End of recovery content---

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325904661&siteId=291194637