usr bin python encode utf-8 from sys import exit import dbhash try db

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
# -*- encode: utf-8 -*-
from sys import exit
import dbhash
try:
db = dbhash.open('c:\db', 'c')
except dbhash.error, err:
exit(err)
else:
print 'good'
try:
file = open('c:\base.txt', 'r')
except IOError, err:
exit(err)
else:
base = map(str.rstrip, file.xreadlines())
file.close()
for x in xrange(len(base)):
db[str(x)] = base[x]
print db[0]