The meaning of a constant does not exist in Python
You can only use uppercase names to indicate that this assignment is a constant, which is actually a variable
Character encoding
In-memory is Unicode
The hard drive is utf-8.
Middle need to convert
Python has the concept of character encoding only when it executes
Python2 default ASCII code
Python3 default Unicode
File operations
Write operation, W does not have a new overwrite, A is append
Name view file name
Encoding viewing character encodings
To see if it is readable
To see if it is writable true false
Display as file characters
Seek to move the cursor position to the beginning of the file to read, Byte, in 0 Utf-8 three characters is a Chinese character
Print the current cursor position
Backwards seek.
Truncation, leaving only 3 bytes, the rest is deleted, this is a write operation, must be with the W parameter
Three additional parameters, mode
Open in Byts format
Decoding in UTF-8 format
Open the binary of the picture
Copy a picture in a binary way
Write absolute path in Windows requires 2 \ \ or the front price is small r
Looping through text
Optimization
Function
To find the maximum value
Minimum value
Sum
Add parameters to the function (number of stars, number of rows)
Defining an parameterless function
You can write the command you call to a function 1
return value
The return value can only be returned once but can be written more than once, returning once after the function ends
The return value of the function is calculated
Python Learning notes section fourth (character encoding + text manipulation + functions)