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?
精彩评论