Python属性错误:模块'serial'没有'serial'属性

2024-09-27 07:17:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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中的所有其他样本都是一样的,我不能使用任何一个。


Tags: 文件代码pyimportwindows错误timeoutserial

热门问题