zoukankan      html  css  js  c++  java
  • python泡菜模块pickle及简单机器学习

    #!/usr/bin/env python
    # -*- coding:utf-8 -*-
    #Author: ss

    import pickle #泡菜模块

    f = open('1.pkl','rb')
    answer = pickle.load(f)
    print(answer)
    f.close() #关闭文件,为了重新打开时指针在开头位置

    while True:
    question = input("请输入要提问的问题:")
    if question == 'get':
    if answer:
    print('已有问题是:{}'.format(list(answer.keys())))
    else:
    print('还没有数据!请提问补充问题!')
    elif question == 'exit':
    print('谢谢使用,再见')
    break
    elif question == 'del':
    while True:
    del_question = input('请输入要删除的问题')
    if del_question in answer:
    del answer[del_question]
    elif del_question == 'quit':
    break
    else:
    print('找不到该问题')
    else:
    for i in list(answer.keys()):
    if question in i:
    print("答案是:{}".format(answer[i]))
    break
    else:
    huida = input("请你告诉我:")
    answer[question] = huida
    f = open('1.pkl','wb')
    pickle.dump(answer,f)
    f.close()
  • 相关阅读:
    Plug It In
    The King's Walk
    Water Testing 匹克定理
    基尔霍夫矩阵
    nginx 常用的命令
    Nginx window安装
    使用nrm管理 npm 镜像仓库
    window 安装node.js
    变量和数据类型
    同步,异步,阻塞,非阻塞
  • 原文地址:https://www.cnblogs.com/ssxsy/p/9116278.html
Copyright © 2011-2022 走看看