import PIL
import ImageGrab
import socket
import io
import atexit
def server():
while True:
print('wait..')
conn, addr = server_socket.accept()
if conn:
print(conn)
print(addr)
connection = conn.makefile('wb')
break
print('connecting..')
try:
stream = io.BytesIO()
ImageGrab.grab().save('1.jpg','JPEG')
stream.write(io.FileIO('1.jpg','r').readall())
stream.seek(0)
connection.write(stream.read())
stream.seek(0)
stream.truncate()
finally:
print('close connection...')
connection.close()
def onExit():
connection.close()
server_socket.close()
print('exit')
server_socket = socket.socket()
server_socket.bind(('0.0.0.0',8000))
server_socket.listen(0)
server_socket.setblocking(1)
while True:
server()
我使用此python脚本发送我的电脑的实时屏幕截图,以便我可以检查手机上的屏幕截图。但不知何故,图片并没有显示出来,有时只显示了一小部分图片。
感谢您提供帮助>。<