python——psutil的使用(获取进程信息)

import psutil
psutil.pids()
[1, 2, 3, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 26, 27, 28, 29, 30, 38, 40, 41, 43, 62, 94, 233, 234,
235, 241, 242, 245, 248, 249, 251, 253, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 360, 379, 385, 390, 406, 463, 464, 465, 466, 467, 468, 469, 470, 493, 510, 511, 513, 515, 518, 519, 520, 521, 522, 523, 526, 528, 534, 536, 566, 567, 568, 570, 577, 578, 596, 616, 644, 850, 852, 856, 868, 931, 935, 1059, 1953, 2078, 2080, 2205, 2240, 2300, 2301, 2348, 2457, 2466, 2471, 2478, 2479, 2546, 2551, 2635, 2647, 2652, 2656, 2668, 2687, 2697, 2704, 2712, 2718, 2719, 2723, 2729, 2737, 2749, 2750, 2757, 2765, 2767, 2776, 2784, 2789, 2795, 2800, 2816, 2818, 2829, 2833, 2836, 2842, 2848, 2854, 2863, 2887, 2969, 2973, 2974, 3049, 3100, 13470, 13555, 16389, 27199, 27786, 27799, 27876, 27923, 27932, 27978, 27979, 27988, 27990, 28008, 28036, 28037]>>> p=psutil.Process(469)

p.name(),p.cwd()
('xfs-eofblocks/s', '/')

p.cpu_times()
pcputimes(user=0.0, system=0.0, children_user=0.0, children_system=0.0)

p.memory_percent()
0.0

p.status()
'sleeping'

原文地址:https://www.cnblogs.com/biaopei/p/8462661.html