Python“classobj”错误
我有此代码,无法运行它,因为我遇到以下错误: TypeError:“classobj”对象不可下标 这是我的代码:Python“classobj”错误,python,Python,我有此代码,无法运行它,因为我遇到以下错误: TypeError:“classobj”对象不可下标 这是我的代码: import cgi import customerlib form=cgi.FieldStorage history = customerlib.find(form["f_name"].value,form["l_name"].value) print "Content-type: text/html" print print """<html> <
import cgi
import customerlib
form=cgi.FieldStorage
history = customerlib.find(form["f_name"].value,form["l_name"].value)
print "Content-type: text/html"
print
print """<html>
<head>
<title>Purchase history</title>
</head>
<body>
<h1>Purchase History</h1>"""
print "<p>you have a purchase history of:"
for i in history: "</p>"
print""" <body>
</html>"""
我在这个文件旁边有customerlib文件。知道怎么修吗
form=cgi.FieldStorage
FieldStorage是一个类,而不是一个对象。您需要实例化它以创建FieldStorage对象:
表单[f_name]上出现错误,因为表单当前是FieldStorage类的别名,而不是FieldStorage类型的对象。通过实例化它,它正在做你认为它应该做的事情
有关如何使用CGI模块的更多详细信息,请查看
FieldStorage是一个类,而不是一个对象。您需要实例化它以创建FieldStorage对象:
表单[f_name]上出现错误,因为表单当前是FieldStorage类的别名,而不是FieldStorage类型的对象。通过实例化它,它正在做你认为它应该做的事情
有关如何使用CGI模块的更多详细信息,请查看
form=cgi.FieldStorage()