2017-01-16 116 views
0

使用pycharm(蟒3)寫python程序,也有該程序的一部分:蟒未解決屬性 - HTTPError

class GraphAPI(object): 
    ... 
    def get_version(self): 
     '''Fetch the current version number of the Graph API being used''' 
     args = {"access_token":self.access_token} 
     try: 
      response = self.request(
       "GET", 
       FACEBOOK_GRAPH_URL + self.version + "/me", 
       params = args, 
       timeout = self.timeout, 
       proxies = self.proxies 
      ) 
     except requests.HTTPError as e: 
      response = json.loads(e.read()) 
      raise GraphAPIError(response) 

然而, 「e.read()」 是在黃色,當上移動鼠標,它表明:

Unresolved attribute reference 'read' for class 'HTTPError',This inspection  

detected names that should resolve but don't. Due to dynamic dispatch and 

duck typing, this is possible in a limited but useful number of cases.Top- 

level and class-level items are supported better than instance items 
+0

歡迎計算器!爲了充分利用網站,提出一些好問題很重要。有關提問的指南,請訪問:http://stackoverflow.com/help/how-to-ask。在這個特定的情況下,你的問題是什麼? –

回答

0

pycharm告訴你,它不明白,這種類型的requests.HTTPError的「E」確實有read()方法。

因此,最有可能的是,您只是缺少正確的導入語句。您必須確保「名稱」requests.HTTPError對您的IDE是已知的。

(和公正的記錄:pycharm通常對這種分配是正確的,所以當pycharm給你一個錯誤的那行,你的代碼有其實是一個問題,將在運行時失敗)

相關問題