nfc_.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:nfc_py 作者: X286 项目源码 文件源码
def __init__(self):
        if sys.platform.startswith('win'):
             ports = ['COM%s' % (i + 1) for i in range(256)]
        elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
            # this excludes your current terminal "/dev/tty"
            ports = glob.glob('/dev/tty[A-Za-z]*')
        elif sys.platform.startswith('darwin'):
            ports = glob.glob('/dev/tty.*')
        else:
            raise EnvironmentError('Unsupported platform')
        self.result = []
        for port in ports:
            try:
                s = serial.Serial(port)
                s.close()
                self.result.append(port)
            except (OSError, serial.SerialException):
                pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号