if else python

Scott Montreuil scott at zml.ca
Tue Nov 24 22:45:37 EST 2015


Hi,
I have an if statement which seems to run both commands and I cannot figure out why. (just learning so I may be missing something obvious) Any ideas?
while True:
 global latit,longt,jlatit,jlongt,mlongt,mlatit
 response = urllib.urlopen(url)
 data = json.loads(response.read())
 latit = data['Data'][0]['Latitude']
 longt = data['Data'][0]['Longitude']
 jlatit = data['Data'][1]['Latitude']
 jlongt = data['Data'][1]['Longitude']
 mlatit = data['Data'][2]['Latitude']
 mlongt = data['Data'][2]['Longitude']
 for i in user1locat:
 if float(i[2]) <= float(latit) <= float(i[3]) and float(i[4]) >= float(longt) >= float(i[5]):
 newlocation = int(i[1])
 screen.addstr(7, 40, "%s at %s" %(user1, i[0]))
 motor1thread = threading.Thread(target=motor1)
 motor1thread.start()
 screen.refresh()
 else:
 screen.addstr(5, 40, "%s is at an unknown location %f %f\n" % (user1, latit, longt))
 newlocation = 200
 motor1thread = threading.Thread(target=motor1)
 motor1thread.start()
 screen.refresh()
 time.sleep(10)


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /