我正在使用 web.py 框架来创建一个简单的 Web 应用程序
我想创建一个单选按钮,所以我编写了以下代码
from web import form
from web.contrib.auth import DBAuth
import MySQLdb as mdb
render = web.template.render('templates/')
urls = (
'/project_details', 'Project_Details',
)
class Project_Details:
project_details = form.Form(
form.Radio('Home Page'),
form.Radio('Content'),
form.Radio('Contact Us'),
form.Radio('Sitemap'),
)
def GET(self):
project_details = self.project_details()
return render.projectdetails(project_details)
当我使用 url 运行代码时,localhost:8080
我看到以下错误
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/web/application.py", line 237, in process
return p(lambda: process(processors))
File "/usr/lib/python2.7/site-packages/web/application.py", line 565, in processor
h()
File "/usr/lib/python2.7/site-packages/web/application.py", line 661, in __call__
self.check(mod)
File "/usr/lib/python2.7/site-packages/web/application.py", line 680, in check
reload(mod)
File "/home/local/user/python_webcode/index.py", line 68, in <module>
class Project_Details:
File "/home/local/user/python_webcode/index.py", line 72, in Project_Details
form.Radio('password'),
TypeError: __init__() takes at least 3 arguments (2 given)
需要在单选按钮中传递什么参数才能避免这个错误