How to output a value: 1, expression. The 2,print () function. 3, the Write () function of the file object
The STR () function returns a user-readable representation.
The repr () function returns the expression of the interpreter's late reading. Special characters in special strings can be escaped
Input () function: Enter, return the output object
Read and Write files:
Open (Filename,mode), returns a File object
FileName: File name, Mode: What pattern is open
Mode has the following modes:
r,rb,r+,rb+,w,wb,w+,wb+,a,ab,a+,ab+
R: Read-only mode open
B: Binary Open
W: Write-only mode open
+: Read/write mode
Pickle module:
Basic data serialization and deserialization implemented by pickle
Pickle.dump (Obj,file[,protocol])
Pickle.load (file)
File
file.close (); Close File
File.flush (); Output the in-memory file to a disk file
File.isatty (); Determine if the file is in the terminal
File.next (); Return to the next line
File.read ([size]); Returns the specified number of bytes read, if not specified or negative, all
File.readline ([size]); Read entire line
File.readlines ([sizeint]); Read Sizeint line
File.seek (Offset[,whence]); Set the current location of the file
File.tell (); Returns the current location of the file
File.write (str); write characters
File.writelines (sequence); write multiple lines
file.truncate ([size]); Truncates the file to a size character starting at the beginning of the first character of the file
Error handling
Try
....//To determine if there is a wrong statement
Except (Runtimeerror,typeerror,nameerror):
....//error code to execute
Else
....//code to execute without errors
Finally
....//The statements executed no matter what
Raise exception: Used to throw the specified exception, the exception that is thrown must be a subclass of exception
With expression: The file object in the//with statement block must be a normal way to clean up
....
Python3 Seventh Day (input and output)