iT邦幫忙

0

問python

今天在學習演算法二元排序法
照理來說我傳進去insert方法的Root是個物件之後
且裡面有data變數>我不懂為何會出錯
而python卻說:AttributeError: 'int' object has no attribute 'data'
我個人的理解是它把node誤認成是int
這裡是出錯代碼:
錯誤訊息:AttributeError: 'int' object has no attribute 'data'
https://ithelp.ithome.com.tw/upload/images/20190131/201100283x4eZSU6R8.pnghttps://ithelp.ithome.com.tw/upload/images/20190131/20110028Y6E0rQ3seV.png

完整code:
https://ithelp.ithome.com.tw/upload/images/20190131/20110028biXaor7cwc.pnghttps://ithelp.ithome.com.tw/upload/images/20190131/20110028HTA5fsiaGY.png

froce iT邦大師 1 級 ‧ 2019-01-31 19:08:44 檢舉
1.把完整的debug丟出來。
2.在insert前先print(i)

不過我跑你的code,應該沒問題啊。
https://ideone.com/VWfPgq
e6319a5b iT邦新手 4 級 ‧ 2019-01-31 20:15:36 檢舉
print(i)那邊我試過了,是int屬性<且有把list各數都print出來
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答