getting ProcessId within Python code

后端 未结 4 1028
渐次进展
渐次进展 2021-01-01 16:19

I am in Windows and Suppose I have a main python code that calls python interpreter in command line to execute another python script ,say test.py .

So test.py is exe

4条回答
  •  旧巷少年郎
    2021-01-01 16:55

    Another option is that the process you execute will set a console window title for himself. And the searching process will enumerate all windows, find the relevant window handle by name and use the handle to find PID. It works on windows using ctypes.

提交回复
热议问题