Variable
The variable name consists of a letter, a number (not the first character), an underscore, and cannot use the keyword
The following keywords cannot be declared as variable names [' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' final ' Ly ', ' for ', ' from ', ' global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' Try ' , ' while ', ' with ', ' yield ']
ID (variable) Gets the address of the variable
Type (variable) to get the variable's kind, type (class) Gets the path of the class
Del Delete a variable
List of special variables: sys.argv[n]
__NAME__: The value of the current file execution is main, and the value is the module name when it is called
Character encoding
1 bits is the smallest representation unit in a computer, and 1 bytes is the smallest storage unit in a computer.
8bits = 1Byte = 1 bytes
1024Bytes = 1KB = 1024 bytes
1024KB = 1MB = 1 million byte = 1 million character = 1 MB
1024MB = 1GB
...
ASCII 256 Each character occupies 8 bits
Unicode Universal Code
utf-32 = 4 bytes
utf-16 = 2 bytes
Utf-8 = 8bits Variable length encoding
English one byte, all Chinese 3 bytes
Europe 2 bytes
Data type numeric type and string type
Numeric type: can only hold one value once defined, cannot be changed, direct access
Category: Numeric int (int) float (float) long (long integer) complex (plural) boolean (true/false)
String type: Quotation marks contain string types (no difference between single-cited and double-cited)
String common features: Remove whitespace, index, length, split, slice
Strip () remove whitespace, or remove other characters
Slipt () split, separated by a space by default. can also be split with other characters
Len () Length slice: such as print (X[1:5]) is also Gu Tou regardless of the tail
Capitalize () Capitalize first letter
Center () Center Display for example: x= ' Hello ' Print (X.center (22, ' # '))
Count (): Count, Gu Tou regardless of the tail, count the number of characters, the space is also counted as a character
EndsWith () at what end
Satrtswith () Start with what
Find () finds the index position of the character, if it is negative, indicates that the lookup failed
Index () indexes
IsDigit () Determine if it is a number
Islower () to determine whether it is all lowercase
Isupper () to determine if it is all uppercase
Lower () convert all to lowercase
Upper () Convert all to uppercase
Isspace () Determine if it is all spaces
Istitle () to determine if it is a title (capitalized in the first letter)
Swapcase () uppercase and lowercase letters flipped
Join () connection
Replace () Replacement
Ljust () Align Left
There are two ways to format a Python string: a percent-semicolon, format-mode
Percent semicolons are relatively old, and format is a more advanced way of trying to replace old ways, both of which are now coexisting
Python Basics (variables, character encodings, data types)