[英]`Serial` attribute missing with the pyserial library (ubuntu 16.04 with python 2.7)
import serial
ser = serial.Serial("/dev/ttyACM0", baudrate = 9600, timeout=1)
while 1:
Data = ser.readline().decode('ascii')
print(Data)
Error: AttributeError: 'module' object has no attribute 'Serial' 错误:AttributeError:“模块”对象没有属性“序列”
You're importing the module, not the class. 您要导入模块,而不是类。 So, you have to use:
因此,您必须使用:
from serial import serial
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.