def sendDataToServer():
global temperature
threading.Timer(5.0, sendDataToServer).start()
print("Sensing...")
readSensor()
readCPUTemperature()
temperature = round(temperature, 1)
print(temperature)
print(humidity)
print(pressure)
temp = "%.1f" % temperature
hum = "%.1f" % humidity
press = "%.1f" % pressure
urllib.urlopen("http://www.teema.club/projectweather/add_data.php?temp=" + temp + "&hum=" + hum + "&pr=" + press).read()
sendDataToServer()
这是我的Python代码,它使用带有一些参数的url向服务器发送一些值。我需要每隔5秒把这些数据发送到服务器。我试着用一根线,但没用。在
有谁能告诉我这是正确的方法吗?在
要按常规计划(固定时间间隔)运行某些代码,可以使用
time.sleep()
,如:代码:
大型上市公司:
^{pr2}$相关问题 更多 >
编程相关推荐