Python DBM Module for Windows?

前端 未结 4 1664
盖世英雄少女心
盖世英雄少女心 2021-01-12 06:44

I would like to use the dbm module on my Windows machine, but it is currently only supported on Unix. http://docs.python.org/library/dbm.html

Does anyone know of a s

4条回答
  •  误落风尘
    2021-01-12 07:22

    Based on the following test on a Windows 7 system using Python 2.7.2 it appears that dbhash is supported on Windows instalations.

    import os
    
    import anydbm
    
    import whichdb
    
    file = os.curdir + '/testdbm'   # define a test file name in the current directory
    
    d = anydbm.open(file, 'c')      # create a new database using the test file name
    
    db_type = whichdb.whichdb(file) # get the dbm database type
    
    print(db_type)                  # display the result
    
    'dbhash'
    

提交回复
热议问题