擅长:python、mysql、java
<blockquote>
<p>I found this script here (...)</p>
</blockquote>
<p>那么,您已经学到了第一课:您不应该依赖“此处”(实际上在大多数其他地方也不应该)找到的复制粘贴代码。实际上,你可以认为你在网上找到的代码中有80%是垃圾(我很慷慨)。<p>
<blockquote>
<p>I'm in process of learning python</p>
</blockquote>
<p>你做了<a href="https://docs.python.org/3/tutorial/" rel="nofollow noreferrer">full official Python tutorial</a>吗?如果没有,那么这就是您真正想要开始的(假设您已经获得了诸如类型、变量、条件、迭代、函数等基本概念,否则您需要<a href="https://greenteapress.com/wp/think-python-2e/" rel="nofollow noreferrer">this</a>)</p>
<blockquote>
<p>For example libvirtd service is stopped and connection is not established and instead going further down the lines into if statement it just prints some errors and stops</p>
</blockquote>
<p>与大多数现代语言一样,Python使用一种名为“异常”的机制来表示错误。这比从函数返回错误代码或特殊值更强大、更可用、更可靠</p>
<p><a href="https://docs.python.org/3/tutorial/errors.html" rel="nofollow noreferrer">This is all explained in the tutorial</a>,所以我不想麻烦发布更正后的代码,只需遵循教程就足以让您自己修复此代码</p>