1.序列化? 序列化是指把内存里的数据类型转变成字符串,以使其能存储到硬盘或通过网络传输到远程,因为硬盘或网络传输时只能接受bytes (1)把字典保存到文件 data = { 'roles': [ {'role': 'monster', 'type': 'pig', 'life': 50}, {'role': 'hero', 'type': 'dog', 'life': 80}, ] } f = open('game_status', 'w') f.write(str(data)) (2)把字…