1. 程式人生 > >AttributeError: 'str' object has no attribute 'decode'

AttributeError: 'str' object has no attribute 'decode'

bsp lin replace sele ons ace pan pytho 分享圖片

執行: python manage.py makemigrations

報錯如下:
技術分享圖片

找到錯誤代碼(line146):query = query.encode(errors=‘replace‘)

解決方法:把decode改為encode即可。

AttributeError: 'str' object has no attribute 'decode'