可以把数据存为字典类型,如下
def get_time():
st = time.strftime("%Y%m%d%H%M%S", time.localtime())
#print(st)
return st
def save_dict(dictObj, saveName):
"""
save a dictionary object into txt file
"""
f = open(saveName ,'w')
f.write(str(dictObj))
f.close()
def read_dict(readName):
'''
read a dictionary object from txt file
'''
f = open(readName ,'r')
a = f.read()
dictObj = eval(a)
f.close()
return dictObj