PyQt 文件 错 误 处 理 的 方 法
发布时间
阅读量:
阅读量
PyQt 文件错误处理的各种方法
记录博文
第一种
异常处理
error = None
fh = None
try:
# open file and read data
except (IOError, OSError) as e:
error = e
finally:
if fh is not None:
fh.close()
if error is not None:
return False, error
return True, "Success"
使用方法
ok, msg = load(args)
if not ok:
QMessageBox.warning(self, "File Error", msg)
第二种
exception = None
全部评论 (0)
还没有任何评论哟~
