我有一个 html 表单,其中包含、Firstname
和和一个按钮。我将数据输入到表格中,然后进入 Berkeelys 数据库。我的代码所做的是它只打印最后一个值。我希望它应该显示与特定键相关的所有值LastName
Age
Gender
ADD
#!/usr/bin/python
import bsddb
import cgi
form = cgi.FieldStorage()
print "Content-type:text/html\n"
Fname = form.getvalue('firstname', '')
Lname = form.getvalue('lastname', '')
Age = form.getvalue('age', 0)
Gender = form.getvalue('gender', '')
#print Fname, Lname, Age
db = bsddb.hashopen("/home/neeraj/public_html/database/mydb.db","w")
db['FirstName'] = Fname
db['LastName'] = Lname
db['Age'] = Age
db['Gender'] = Gender
db.close()
db = bsddb.hashopen("/home/neeraj/public_html/database/mydb.db","r")
#db = bsddb.hashopen("/home/neeraj/public_html/database/mydb.db")
print db['FirstName'], db['LastName'], db['Age'], db['Gender']
db.close()
print db