在关闭之前,搁板未同步到磁盘

问题描述 投票:0回答:1

将python的版本从3.5更改为3.7后,在调用sync方法时,shelfve不再写入磁盘。但是,当我使用python 3.5时,确实可以。

我还注意到在python 3.7上,'db'扩展名被附加到搁置的数据库文件中。

有人知道原因吗,有没有解决方法?

python shelve
1个回答
0
投票

结果是我缺少python3.7-gdbm软件包(这是Ubuntu Xenial服务器)。

可以使用apt-get安装:

sudo apt-get install python3.7-gdbm

安装gdbm软件包后,python将开始将货架存储为GNU dbm而不是Berkeley DB:

$ file *
shelve_obj_berkley:            Berkeley DB (Hash, version 9, native byte-order)
shelve_obj_gdbm:               GNU dbm 1.x or ndbm database, little endian, old
© www.soinside.com 2019 - 2024. All rights reserved.