牛逼的泡菜(Pickle模块应用)

在学习决策树时,对决策树的存储使用了这样一段代码

def storeTree(inputTree,filename):
    import pickle
    fw = open(filename,'w')
    pickle.dump(inputTree,fw)
    fw.close()
    
def grabTree(filename):
    import pickle
    fr = open(filename)
    return pickle.load(fr)

于是可以看出Pickle模块是用来进行数据的本地存储的,其用法如下
http://python.usyiyi.cn/python_278/library/pickle.html
https://www.google.com.hk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=7&ved=0ahUKEwj98Yrqj8HOAhWPJSwKHWvrAHkQFghGMAY&url=http%3a%2f%2fwww%2epythonclub%2eorg%2fmodules%2fpickle&usg=AFQjCNERyGqaqohWLqNviEIifQK7mIrt9Q&sig2=rhOdVgFaPs7nu0sdt1jc1g

你可能感兴趣的:(牛逼的泡菜(Pickle模块应用))