A, Python pickle
Python's Pickle module is Python objects into .pkl suffix file, you need to use it quickly converted to Python objects.
Avoiding multiple database read operation, improves the efficiency of program execution.
Which is generally divided into three steps: import, store and read
-
import pickle
-
storage:
import pickle
# Storage
Open with (filename, ' W') AS F: the pickle.dump (save_object, F) # filename of the form xxx.pkl
# After storage, automatically writing .pkl file suffix save_obj
3. Read (pandas.read_pkl pickle module and the module pandas)
Import the pickle with Open ( ' filename.pkl ' , ' R & lt ' ) AS F: save_object = the pickle.load (F) # after reading, save_object Python object directly
Two, csv file reading and writing
1.csv file brief
Comma Separated Values file full name, a comma-delimited plain text file
For example in the form of partial data fifa19 datasets:
2. csv module reads:
Import csv with open (csv_file_name, ' r ' ) AS CSV_File: reader = csv.reader (CSV_File) # But this csv The reader can only be traversed once, the next time with the need to open the file
3. pandas module
pandas module containing a module to read various documents, including xlxs, csv, pickle like:
The following document is read player_data.csv fifa19 data sets, the data type is returned panda.DataFrame: