2
我尝试使用python 3和pyvisa 1.8与GPIB设备进行通信。如何设置pyvisa异常处理程序?
但如何区分不同类型的excptions。
例如:
try:
visa.ResourceManager().open_resources('COM1')
exception visa.VisaIOError:
<some code>
时打开失败,它产生一种普遍的例外VisaIOError,但我怎么能知道,是端口忙或端口不存在,或者其他什么东西?
,如:
try:
visa.ResourceManager().open_resources('COM1')
exception <1>:
# device busy
exception <2>:
# device does not exist
exception ...
我应该怎么正确的位置< 1> 2 <>等捕获不同类型的例外?
感谢