“Python异常处理调试”的版本间的差异
跳到导航
跳到搜索
(创建页面,内容为“=eg= <pre> def connect(self): try: #print('try key connect') self._key_connect() print('ssh key connect sucess')…”) |
|||
(未显示同一用户的3个中间版本) | |||
第1行: | 第1行: | ||
=eg= | =eg= | ||
<pre> | <pre> | ||
+ | |||
+ | # Exception 常规错误的基类 | ||
def connect(self): | def connect(self): | ||
第16行: | 第18行: | ||
print('ssh password connect failed') | print('ssh password connect failed') | ||
</pre> | </pre> | ||
+ | =see also= | ||
+ | [https://www.runoob.com/python/python-exceptions.html Python 异常处理] | ||
+ | |||
+ | [https://blog.csdn.net/flower_517/article/details/89227113 Python脚本的调试和分析] | ||
+ | |||
+ | [[category:python]] |
2020年10月10日 (六) 09:15的最新版本
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')