saveLoadVar.py
import json
def save_var(v, filename):
with open(filename, 'w') as file_obj:
json.dump(v, file_obj)
file_obj.close()
def load_var(filename):
with open(filename) as file_obj:
v = json.load(file_obj)
file_obj.close()
return v
使用: