保存数据的最佳方法 [英] Best method of saving data

查看:53
本文介绍了保存数据的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开设了一个课程,我想在其中跟踪学生的统计数据.我打算稍后制作一个 GUI 来操作这些数据.

I've made a class in which I want to keep track of stats of students. I intend to make a GUI later to manipulate this data.

我的主要问题是:保存和以后检索这些数据的最佳方法是什么?

My main question is: what is the best way to save and later retrieve this data?

我读过关于 pickle 和 JSON 的文章,但我并不真正了解它们是如何工作的(尤其是关于它们如何保存数据,例如采用哪种格式和位置).

I've read about pickle and JSON, but I don't really get how they work (especially about how they save the data, like in which format and where).

推荐答案

对于持久数据(存储有关学生的信息),数据库是一个不错的选择.正如已经提到的,Python 附带了 Sqlite3,它通常足够好,至少用于开发目的.

For persistent data (storing info about students), a database is a good choice. As already mentioned, Python comes shipped with Sqlite3 which is often good enough, for development purposes at least.

将 Sqlite 引入 Python 很容易 - 只需在源代码文件中导入库并打开与数据库的连接.请参阅 python 文档.

Introducing Sqlite to Python is easy - just import the library in your source code file and open a connection to your database. Refer to the python documentation.

编辑:发现一个关于 Python + Sqlite 的新教程,看起来似乎不错.

EDIT: Found a new tutorial about Python + Sqlite that seems good.

这篇关于保存数据的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆