一、pickle模块
>>>import pickle #引用泡菜模块
>>>pickle_file = open( 'city_data.pkl', 'wb') #打开一个泡菜文件(二进制写入模式打开)
>>>pickle.dump(city_list) #将city_list列表倒入(利用pickle模块换算)二进制文件pickle_file中
>>>pickle_file.close() #关闭泡菜文件city_data.pkl
>>>pickle_file = open('city_data.pkl', 'rb') #打开泡菜文件city_data.pkl(二进制读取模式打开)
>>>city = pickle.load(pickle_file) #读取泡菜文件对象 ,将city_list文件中保存的列表或字典传入变量city中