Web2py - request.vars.values()[0] - can't define
What would be the possible reasons for getting the error:
IndexError: list index out of range
Whilst it's try开发者_高级运维ing to define:
partialstr = request.vars.values()[0]
As pointed out here, you should use request.vars.partialstr
rather than request.vars.values()[0]
-- the former will simply return None
if partialstr
doesn't exist.
If the list-like thing returned by request.vars.values()
has no elements, then this error would be expected -- you would be trying to access the first element in an empty list.
Try displaying len(request.vars.values())
. If it is 0
then that's your problem.
精彩评论