我想獲取我自己寫的模塊里的某一個函數的返回值,但是提示AttributeError錯誤 錯誤詳情:AttributeError: module '__main__' has no attribute 'Student' 具體代碼: 出現錯誤的是第10行,很茫然,不知道為什么會出現這個錯誤.請大神指點一下
1 回答

慕姐8265434
TA貢獻1813條經驗 獲得超2個贊
getattr(對象,名稱) 返回這個對象屬性名的值,name這里必須是字符串,
getattr(x,'foobar') 相當于,x.foobar 你這里報錯的原因是因為沒有Student這個屬性(ret['status']的結果應該是Student)
添加回答
舉報
0/150
提交
取消