serialwin32.py中有如下语句:
raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))
如果捕获到这个异常,因为其中的中文被经过repr处理了,获得的e.message为
could not open port 'COM4': WindowsError(2, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')
此时,要想获取中文的信息内容,需要执行eval('\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')。而直接执行eval("could not open port 'COM4': WindowsError(2, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')")是不能解析的。
请问有什么方便些的处理方法,可以直接将“could not open port 'COM4': WindowsError(2, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')”中的中文能打印出来
raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))
如果捕获到这个异常,因为其中的中文被经过repr处理了,获得的e.message为
could not open port 'COM4': WindowsError(2, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')
此时,要想获取中文的信息内容,需要执行eval('\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')。而直接执行eval("could not open port 'COM4': WindowsError(2, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')")是不能解析的。
请问有什么方便些的处理方法,可以直接将“could not open port 'COM4': WindowsError(2, '\xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xce\xc4\xbc\xfe\xa1\xa3')”中的中文能打印出来