开发者

python and process

What is the best wa开发者_JAVA技巧y in python find the process name and owner?

Now i use WMI, but this version is too slow.


By using https://github.com/giampaolo/psutil:

>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.name()
'python.exe'
>>> p.username()
'giampaolo'
>>> 


Process name: is sys.argv[0] not sufficient for your purposes?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜