Python异常处理调试

来自linux中国网wiki
Evan讨论 | 贡献2020年10月10日 (六) 09:15的版本 →‎see also
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

eg


# Exception	常规错误的基类

    def connect(self):
        try:
            #print('try  key  connect')
            self._key_connect() 
            print('ssh key connect sucess')
        except Exception as e:
            print("kye err:",e)
            print('ssh key conect failed, trying to password connect...')
            try:
                self._password_connect()  # 密码登录
                print('ssh password connect sucess')
            except:
                print('ssh password connect failed')

see also

Python 异常处理

Python脚本的调试和分析