擅长:python、mysql、java
<p>在检查文档<a href="https://pythonhosted.org/psutil/#functions" rel="nofollow noreferrer">here</a>之后,我在psutil中没有看到<code>get_process_list()</code>函数,根据<a href="https://github.com/giampaolo/psutil/blob/master/HISTORY.rst#050 -2012-06-27" rel="nofollow noreferrer">this</a>,它已被弃用。在</p>
<p>也许你应该试试函数-<code>process_iter()</code>-documentation<a href="https://psutil.readthedocs.io/en/latest/#psutil.process_iter" rel="nofollow noreferrer">here</a></p>
<p>它生成一个迭代器,将系统中的所有进程作为进程类对象返回。在</p>
<p>然后,您可以使用<code>list(..)</code>将它们转换为列表(如果list是您真正想要的),或者直接在for循环中使用迭代器,如果您只想迭代它们(如果您只想逐个迭代它们,转换为list将是不必要的开销)。在</p>
<p>示例-</p>
<pre><code>for proc in psutil.process_iter():
<do your logic>
</code></pre>
<p>或者如果你想要这个名单-</p>
^{pr2}$