bsddb for k, v in db.items(): do order the numbers ?
martijn_at_gamecreators.nl
Date: 02/28/05
- Next message: DENG: "Share your SciTEGlobal.properties pls~~~~"
- Previous message: pyguy2_at_gmail.com: "Re: Python - what is the fastest database ?"
- Next in thread: Christopher De Vries: "Re: bsddb for k, v in db.items(): do order the numbers ?"
- Reply: Christopher De Vries: "Re: bsddb for k, v in db.items(): do order the numbers ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Feb 2005 08:30:59 -0800
WHen I use the code below and printing all the results i get this:
------
0 1 10
11 2 3
4 5 6
7 8 9
------
But I want
------
0 1 2
3 4 5
6 7 8
9 10 11
------
Thanks for helping
import bsddb
def addRow(key,val):
db[key] = key
print key,
db = bsddb.btopen('test3.db','n')
#maar 3 kolomen
for i in range(4):
addRow('%d'%(i*2+0+i),'test%d'%(i*2+0+i))
addRow('%d'%(i*2+1+i),'test%d'%(i*2+1+i))
addRow('%d'%(i*2+2+i),'test%d'%(i*2+2+i))
#-----
print 'kolom1','kolom2','kolom3'
p=0
for k, v in db.items():
if p == 0:
p = p+1
print v,
elif p == 1:
p = p+1
print v,
elif p == 2:
p=0
print v,
print
- Next message: DENG: "Share your SciTEGlobal.properties pls~~~~"
- Previous message: pyguy2_at_gmail.com: "Re: Python - what is the fastest database ?"
- Next in thread: Christopher De Vries: "Re: bsddb for k, v in db.items(): do order the numbers ?"
- Reply: Christopher De Vries: "Re: bsddb for k, v in db.items(): do order the numbers ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]