Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
reqUser = friends.UserFriends.gql("where udid =:1", str(udid) ).get() reqUserName = reqUser.userName
这是我的代码我想知道如何处理这个错误,这个错误出现在第 2 行
你可以使用 python 的 try/except 对。
reqUser = friends.UserFriends.gql("where udid =:1", str(udid) ).get() try: reqUserName = reqUser.userName except AttributeError: reqUserName = "No username found!"
这仅捕获 AttributeError 异常,因此仍会引发其他任何异常。