我有一個LED標誌,我也發送天氣數據,但遇到溫度問題,讀取小數點,我相信這個標誌不會讀取,我得到這個錯誤。將數據點轉換爲整數蟒蛇
File "/usr/local/lib/python3.4/dist-packages/pyledsign/minisign.py", line 276, in processtags
data=data.replace('<f:normal>',str(normal,'latin-1'))
AttributeError: 'float' object has no attribute 'replace'
這是我的代碼下面的標誌。發送此標記時會出現此錯誤。
mysign.queuemsg(data=current_weather.temperature, speed=2).
所以我想知道我怎麼能說天氣溫度總是讀爲int。將int()放在它周圍不起作用。
#!/usr/bin/python
import datetime
import forecastio
from pyledsign.minisign import MiniSign
def main():
"""
Run load_forecast() with the given lat, lng, and time arguments.
"""
api_key = 'my api key'
lat = 42.3314
lng = -83.0458
forecast = forecastio.load_forecast(api_key, lat, lng,)
mysign = MiniSign(devicetype='sign')
print ("===========Currently Data=========")
current_weather = forecast.currently()
print (current_weather.summary)
print (current_weather.temperature)
mysign.queuemsg(data=current_weather.summary, speed=2)
mysign.queuemsg(data=current_weather.temperature, speed=2)
mysign.sendqueue(device='/dev/ttyUSB0')
print ("===========Daily Data=========")
by_day = forecast.daily()
print ("Daily Summary: %s" %(by_day.summary))
mysign.queuemsg(data=by_day.summary)
mysign.sendqueue(device='/dev/ttyUSB0')
if __name__ == "__main__":
main()
它需要一個字符串,而不是浮動或整數 –