import serial import time import urllib.request from urllib.parse import urlencode s=serial.Serial("COM8"); while(1): if(s.inWaiting()>0): rida=s.readline().decode("ascii").strip() print(rida) vastus=urllib.request.urlopen("http://greeny.cs.tlu.ee/~jaagup/2015/robootika/teine/haldus.php?andmed="+rida) s.write(bytearray([int(vastus.read().decode('utf8'))])) # s.write(int(vastus.read().decode('utf8'))) time.sleep(0.5)