我在Windows 7中使用Python3,并安装了pyserial 3.3。我用以下行代码创建了一个名为serial.py的文件:
import serial
ser = serial.Serial('COM4', 9600, timeout=0)
ser.write(b'mymessage')
它将显示以下错误消息:
attributeError: module 'serial' has no attribute 'Serial'
对于他们的documentation中的所有其他样本都是一样的,我不能使用任何一个。
哈!
问题是我的文件名。我的python包使用了相同的文件名!
我将文件名从
serial.py
更改为test.py
,它开始工作。相关问题 更多 >
编程相关推荐