Head First Python--test for pickle load

import os
import pickle
import nester

os.chdir('d:/Python_test')
new_man = []
new_other = []
try:
    with open('man.txt', 'rb') as man_file:
        new_man = pickle.load(man_file)
    with open('other.txt', 'rb') as other_file:
        new_other = pickle.load(other_file)
except IOError as err:
    print('File error! ' + str(err))
except pickle.PickleError as perr:
    print('Pickling error: ' + str(perr))

nester.print_lol(new_man)
nester.print_lol(new_other)

你可能感兴趣的:(Python)