reqUser =  friends.UserFriends.gql("where udid =:1", str(udid) ).get()
reqUserName = reqUser.userName

This is my code i want to know how to handle this error, this error comes at line 2

有帮助吗?

解决方案

you can use pythons try/except pair.

reqUser =  friends.UserFriends.gql("where udid =:1", str(udid) ).get()
try:
    reqUserName = reqUser.userName
except AttributeError:
    reqUserName = "No username found!"

this catches only AttributeError exceptions, so anything else will still be raised.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top