开发者

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 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜