电脑和树莓派在同一局域网内,先在电脑和树莓派创建python运行环境,然后在树莓派中用python运行rpi.py;在电脑上运行computer.py;电脑上输入字符即可在树莓派上即时显示!
rpi.py
#coding:utf-8
#import necessary package
import socket
import time
import sys
HOST_IP = 192.168.31.151 #树莓派的IP地址
HOST_PORT = 8888
print(Starting socket: TCP...)
#1.create socket object:socket=s
1