Python raspberry pi串行sim868登录不正确

Python raspberry pi串行sim868登录不正确,python,raspberry-pi,pyserial,Python,Raspberry Pi,Pyserial,为什么有时它会起作用 我试着按命令打电话 我怎样才能修好它 import serial import time port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=1) port.write('AT'+'\r\n') print port.read(10) time.sleep(.1) 输出 也许串行端口保持打开状态,您需要在再次访问它之前将其关闭?尝试将延迟置于读取之前: time.sleep(.1) print port.

为什么有时它会起作用

我试着按命令打电话

我怎样才能修好它

import serial
import time
port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=1)
port.write('AT'+'\r\n')
print port.read(10)
time.sleep(.1)
输出

也许串行端口保持打开状态,您需要在再次访问它之前将其关闭?

尝试将延迟置于读取之前:

time.sleep(.1)
print port.read(10)