如何在Python中保存整个项目
你好,我用Python开发了一个小游戏,使用ZODB作为数据库处理的后端。我以前从未做过游戏编程。我希望有人能告诉我如何保存当前的游戏,然后使用Python重新加载它。数据库文件名是 data.fs,我的文件夹中还有另外三个 ZODB 文件。其中一个用于锁定,我不知道。
Hello I have developed a small game in python using ZODB as backend for DB processing.I have never done game programming before.I was hoping if someone can tell me as to how I can save my current game and then reload it using python.The database filename is data.fs and there are three more ZODB files in my folder.One being for locks rest I'm not aware about.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你的具体情况,但也许 ZODB 对此有点矫枉过正。检查第一个 pickle 和 anydbm,两者都位于标准库中。如果它们不足以满足您的要求,您可以选择 ZODB。
在 ZODB 中,一旦连接,您可以将任何你想要的东西,就像使用普通的 Python 字典一样。
您还可以使用 repoze.zodbconn 来方便配置、启动时的连接和关闭当您的程序存在时正确。
I don't know your particular case but maybe ZODB is overkill for this. Check first pickle and also anydbm, both at the standard library. If they are not enough for your requirements you can then go for ZODB.
In ZODB, once you are connected, you can put anything you want inside as you would with a plain Python dictionary.
You can also use repoze.zodbconn to facilitate the configuration, the connection at startup and closing it properly when your program exists.