0
類預報(BoxLayout的): 日出= NumericProperty()爲什麼從Controls類中顯示爲0的預測類傳遞的值。我做錯了什麼?
def weather_retrieved1(self, request, data):
data = json.loads(data.decode()) if not isinstance(data, dict) else data
# some code here
self.sunrise=(data['sys']['sunrise'])
類控制(BoxLayout的):
日出= NumericProperty()
預測=預報()
def __init__(self, *args, **kwargs):
super(Controls, self).__init__(*args, **kwargs)
self.forecast.bind(sunrise=self.forecast.weather_retrieved1)
# for testing
Clock.schedule_interval(self.test, 1)
def test(self, *args):
print self.sunrise # i get as an output 0
請幫助我理解爲什麼提交代碼時有它正確格式化,這並不工作 – lesio 2014-10-16 23:42:43
使用4個空格的縮進。 – inclement 2014-10-17 12:18:33
我很抱歉,但我不明白你的意思。當我複製代碼時,我使用了四個空格。當我運行該程序時,問題在於,我以某種方式錯誤地傳遞了日出值並得到錯誤的結果。我尋找答案,我做錯了什麼 – lesio 2014-10-17 13:25:35