这是代码:
import MySQLdb
from socket import *
import time
address = ( '192.168.1.177', 5000)
client_socket = socket(AF_INET, SOCK_DGRAM) #Set Up the Socket
client_socket.settimeout(30) # wait 30 seconds for a response
while(1): #Main Loop
data = "send" #Set data to Blue Command
client_socket.sendto(data, address) #send command to micro
rec_data, addr = client_socket.recvfrom(1024) #Read response from micro
print rec_data #Print the response from micro
sdata = rec_data.split(',') #csv string split
Vrms = 123.1 #float(sdata[0]) #
Irms = 213.45 #float(sdata[1])
RP = 10.1 …Run Code Online (Sandbox Code Playgroud)