获取所有进程pid
[root@bogon python_auto]# vim process.py
!/usr/bin/env python
import psutil
pids = psutil.pids()
print pids
执行文件,查看系统上所有进程pid
[root@bogon python_auto]# python process.py
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 38, 39, 41, 42, 72, 148, 149, 156, 157, 158, 287, 288, 299, 381, 744, 916, 917, 951, 1203, 1228, 1298, 1309, 1313, 1330, 1331, 1356, 1365, 1366, 1409, 1416, 1456, 1538, 1551, 1562, 1570, 1581, 1629, 1635, 1637, 1639, 1641, 1643, 1653, 1654, 1664, 1667, 1683, 1753, 1759, 1799, 1810, 1816, 1826, 1836, 1844, 1845, 1863, 1871, 1875, 1877, 1897, 1901, 1902, 1905, 1906, 1908, 1917, 1918, 1920, 1922, 1923, 1925, 1928, 1931, 1934, 1936, 1938, 1939, 1942, 1944, 1953, 1955, 1958, 1977, 1981, 1982, 1983, 2010, 2012, 2013, 2014, 2029, 21686, 21816, 27926, 33028, 33816, 33829,