我是python编程的新手,正在阅读the headfirst python book。我写了正确的代码,但是为什么不起作用?
import cgi
form_data = cgi.FieldStorage()
以下行出现错误:
athlete_name = form_data['Which_Athelete']
,错误是:
Traceback (most recent call last):
File "C:/Users/Hamza Shah/Desktop/Headfirst Python/chapter7/webapp/cgi-bin/generate_timing_data.py", line 7, in <module>
athlete_name = form_data['Which_Athelete']
File "C:\Users\Hamza Shah\AppData\Local\Programs\Python\Python37-32\lib\cgi.py", line 534, in __getitem__
raise KeyError(key)
KeyError: 'Which_Athelete'
答案 0 :(得分:0)
以下代码的输出是
FieldStorage(None, None, [])
其中没有名为Whoth_Athlete的键。因此,这给你一个错误