Second, variable, character encoding
Variables is used to store infomation to is referenced and manpulated in a computer program. They also provide a, labeling data with a descriptive name, so we program can is understood more clearly by the Rea Der and ourselves. It's helpful to think of variables as containers, that's hold infomation. Their sole puepose is to label and store data in memory. This dat can and is used Thougout your program.
Rules for defining variables:
* Variable names can only be any combination of letters, numbers, or underscores
* The first character of a variable name cannot be a number
* The following keywords cannot be declared as variable names:
[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']
The Python interpreter encodes the content when it loads the code in the. py file (default Ascill)
ASCII (American Standard Code for Information interchange, United States Standards Information Interchange Code) is a set of computer coding systems based on the Latin alphabet, mainly used to display modern English and other Western European languages, which can be used up to 8 Bit to represent (one byte), that is: 2**8 = 256-1, so the ASCII code can only represent a maximum of 255 symbols.
About Chinese
To deal with Chinese characters, programmers designed GB2312 for Simplified Chinese and big5 for traditional Chinese.
GB2312 (1980) contains a total of 7,445 characters, including 6,763 Kanji and 682 other symbols. The inner code range of the Chinese character area is high byte from B0-f7, low byte from A1-fe, occupy code bit is 72*94=6768. 5 of these seats are d7fa-d7fe.
GB2312 supports too few Chinese characters. The 1995 Chinese character extension specification GBK1.0 contains 21,886 symbols, which are divided into Chinese characters and graphic symbol areas. The Chinese character area consists of 21,003 characters. 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 platform must support GB18030, the embedded products are not required. So mobile phones, MP3 generally only support GB2312.
From ASCII, GB2312, GBK to GB18030, these coding methods are backwards compatible, meaning that the same character always has the same encoding in these scenarios, and the latter standard supports more characters. In these codes, English and Chinese can be handled in a unified manner. The method of distinguishing Chinese encoding is that the highest bit of high byte is not 0. According to the programmer, GB2312, GBK, and GB18030 belong to the double-byte character set (DBCS). Some Chinese Windows default internal code or GBK, you can upgrade to GB18030 through the GB18030 upgrade package. But GB18030 relative GBK increases the character, the ordinary person is difficult to use, usually we still use the GBK to refer to the Chinese Windows inside code.
Unicode (Uniform Code, universal Code, single code) is a character encoding used on a computer. Unicode is created to address the limitations of the traditional character encoding scheme, which sets a uniform and unique binary encoding for each character in each language, which specifies that characters and symbols are represented by at least 16 bits (2 bytes), that is: 2 **16 = 65536,
Note: Here is a minimum of 2 bytes, possibly more
UTF-8, which is compression and optimization of Unicode encoding, does not use a minimum of 2 bytes, but instead classifies all characters and symbols: the contents of the ASCII code are saved with 1 bytes, the characters in Europe are saved in 2 bytes, and the characters in East Asia are saved in 3 bytes ...
Import Getpass
_username = "Jingyuwang"
_password = "wxl952780"
Username = input ("Username:")
Password = getpass.getpass ("Password:")
If _username = = Username and _password = = password:
Print ("Welcome user {name} login ...". Format (Name=username))
Age_of_oldboy = 66
Count = 0
While count<3:
Guess_age = Int. = Int (Input ("Please input Age guess:"))
if Age_of_oldboy = = Guess_age:
Print ("Yes,you gei it")
Elif Age_of_oldboy >= guess_age:
Print ("Think older")
else:
Print ("Think younger")
Count +=1
if Count = = 3:
Continue_confirm = input ("Does want to keeping guessing. N:quit; Y:keep ")
if (continue_confirm! = ' N '):
Count = 0
Else
Print ("quit!")
Else
Print ("You have tried too many timers...fuck off")
Else
Print ("Invalid username or password")
My "Bian" Python net lesson second lesson