假设设备连接已经建立,可以使用以下代码将每个命令发送到设备并读取响应:

with open('Commands.txt', 'r') as f: commands = f.readlines() print(commands)

for command in commands: cmd = command.strip() device.send(cmd + '\n') response = device.recv(1024) print(response) # 或者将响应写入文件,取决于你的需求。

发送commandstrip到设备后面怎么写with openCommandstxt r as f commands = freadlines printcommandsfor command in commands printcommandstrip

原文地址: https://www.cveoy.top/t/topic/hcJt 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录