我想在字典中使用new_variable = current_user.pub
使用從數據庫酒館列中的數據,但我得到這個錯誤AttributeError: 'NoneType' object has no attribute 'pub'
對此的任何幫助深表感謝在Python字典中使用current_user變量?
這裏是我的全部代碼`
pins = {
4 : {'name' : 'Channel 1', 'board' : 'esp8266', 'topic' : '/4', 'state' : 'False'},
5 : {'name' : 'Channel 2', 'board' : 'esp8266', 'topic' : '/5', 'state' : 'False'}
}
variable = pins[4]['topic']
new_variable = current_user.pub
pins[4]['topic'] = new_variable
謝謝你
你在哪裏定義'current_user'? – Dadep
因爲'current_user'沒有定義,所以'NoneType'沒有'pub'屬性,創建'current_user'來使用它 – depperm
嘿謝謝回覆 實際上'''''''''''列 –