访问时出现键错误请求.POST

2024-04-19 17:16:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python中得到了关键错误。在

这样的错误。。。。。。。。。。在

KeyError at /python_tutor/
'user_script'

密码是

^{pr2}$

请给我解决这个问题的办法?在


Tags: 密码错误scriptat关键keyerror办法user
2条回答

mycode = request.POST.get('user_script', None)

这意味着键(user_script)不存在于字典(request.POST)中,这表明它没有被提交。尝试:

if 'user_script' in request.POST:
    print "My Script =", request.POST["user_script"]
    mycode = request.POST["user_script"]

相关问题 更多 >