开发者

python and process

开发者 https://www.devze.com 2022-12-21 04:09 出处:网络
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:

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

精彩评论

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

关注公众号