First, the data type
The types of data that Python can directly handle are: integers, floating-point numbers, strings, booleans, and null values.
Integer
Floating point number
String: Enclose a single quotation mark in double quotation marks to output i ' m ok.
You can also use \ to implement, \ nthe line \ t table
Multi-line string with "'"
Boolean: Boolean values can be performed with or non-op/with and or not
Null value
Second, the variable
A = 1/a = "Nadech" is different from Java, when Python declares a variable without specifying the type of the variable, the direct assignment is OK
When executing a =1, thepython interpreter actually performs two steps: Create an integer 1, declare the variable A, and point the variable A to the integer 1
Constant PI, even if declared in order to be constant, but Python does not have a true constant
Integer division in Python is accurate:10/3 = 3.333333333333 Floor Division: 10//3=3
Three, string and encoding
ASCII encoding, can only encode 127 characters, so the number is limited
GB2312 (2 bytes) China is used to write Chinese and is built on ASCII code and cannot conflict with ASCII. After that, Korea and Japan all have their own code and so on.
Unicode encoding (2 bytes), unifying all languages into a set of encodings. The disadvantage is 2 bytes, which is a waste of storage space.
UTF-8 encoding encodes a Unicode character into 1-6 bytes based on a different number size, the commonly used English letter is encoded in 1 bytes, the kanji is usually 3 bytes, and only the very uncommon characters are encoded into 4-6 bytes. The advantage of UTF-8 is that it is compatible with ASCII code and saves space.
When editing with Notepad, the UTF-8 characters read from the file are converted to Unicode characters into memory, and when the edits are complete, the conversion of Unicode to UTF-8 is saved to the file.
When you browse the Web, the server converts dynamically generated Unicode content to UTF-8 and then to the browser.
Python Note II (data types and variables, strings, and encodings)