import light
import urllib2
true = 1
while(true):
try:
response = urllib2.urlopen('http://192.168.1.6/light.php')
status = response.read()
except urllib2.HTTPError, e:
print e.code
except urllib2.URLError, e:
print e.args
print status
if status=='17':
light.lighton();
elif status=='0':
light.lightoff();
答案 0 :(得分:2)
狂野猜测:您的回复以换行符终止。试试这个:
status = status.strip()
print status
if status=='17':
light.lighton();
elif status=='0':
light.lightoff();