# 保存字典
with open('E:/AApaper/Model/cnn/'+'vocab.json','a') as outfile:
json.dump(vocab,outfile,ensure_ascii=True)
outfile.write('\n')
with open('E:/AApaper/Model/cnn/'+'vocab.json', encoding='utf-8') as f:
line = f.readline()
vocab = json.loads(line)
f.close()
print(vocab)
#列表保存
np.savetxt(path+'myVocabList.txt', myVocabList,fmt="%s", delimiter=",")
p0V, p1V, pAb = trainNB0(array(trainMat), array(listClasses))
#以逗号分隔保存二维数组
np.savetxt(path + 'p0V.txt', p0V, delimiter=",")
多维数pAb是数组,把数组存放到另一个数组中
pAbarray[0]=pAb
np.savetxt(path + 'pAb.txt', pAbarray)