當前位置:成語大全網 - 新華字典 - 執行python腳本時,返回:AttributeError: 'NoneType' object has no attribute 'open_session',原因?

執行python腳本時,返回:AttributeError: 'NoneType' object has no attribute 'open_session',原因?

關鍵在於我圈出來的那句話:

意思是屬性異常,結果是None,所以也就沒有open_session方法,所以自然不能調用了。

妳檢查下妳的代碼,self._transport這個變量的值,目前從這異常報錯來看,self._transport已經是None(即空)了。

可以print壹下看self._transport發生了什麽,也可以用第三方的ide工具(比如pycharm)壹步壹步的debug檢測壹下到底哪壹個步驟出現了錯誤