开发者

Web2py - request.vars.values()[0] - can't define

开发者 https://www.devze.com 2023-03-26 15:21 出处:网络
What would be the possible reasons for getting the error: IndexError: list index out of range Whilst it\'s try开发者_高级运维ing to 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 Noneif 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号