首先,我将此信息转储到名为“ save0.pickle”的文件中。
with open('save0.pickle', 'wb') as outfile:
pickle.dump({
'world_w': world.w,
'world_h': world.h,
'world_world': world.world,
'player_icon': player.icon,
'player_x': player.x,
'player_y': player.y,
'player_item': player.item,
}, outfile)
这很好用,但是当我尝试将文件信息加载到变量中时出现错误,如下所示。
with open('save0.pickle', 'r') as infile:
d = pickle.load(infile)
错误:UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 21: character maps to <undefined>
任何帮助将不胜感激。