How to get the process ID of python programm?

Viewed 24

Is there a way to get the process ID (PID) of a python program?

The program was started from the command line.

1 Answers

this should do it:

import os
pid = os.getpid()
print(pid)
Related