相关文章推荐
乐观的洋葱  ·  mybatis - 通用mapper ...·  1 年前    · 
豪情万千的土豆  ·  Node.js 小知识 — ...·  1 年前    · 
Python2.7.6(default,Mar222014,22:59:56)[GCC4.8.2]onlinux2Type"help","copyright","cred... Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.cpu_times()
cputimes(user=917266.55, nice=496050.34, system=87356.22, idle=2982555.63, iowait=14894.21, irq=2644.89, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
>>> psutil.pids()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'pids'
你的psutil 是怎么安装的 在什么平台运行的?
先用dir 看哈你装的psutil 有没有这个pids 的属性
>>> dir(psutil)
['ABOVE_NORMAL_PRIORITY_CLASS', 'AF_LINK', 'AccessDenied', 'BELOW_NORMAL_PRIORITY_CLASS', 'BSD', 'CONN_CLOSE', 'CONN_CLOSE_WAIT', 'CONN_CLOSING', 'CONN_DELETE_TCB', 'CONN_ESTABLISHED', 'CONN_FIN_WAIT1', 'CONN_FIN_WAIT2', 'CONN_LAST_ACK', 'CONN_LISTEN', 'CONN_NONE', 'CONN_SYN_RECV', 'CONN_SYN_SENT', 'CONN_TIME_WAIT', 'Error', 'FREEBSD', 'HIGH_PRIORITY_CLASS', 'IDLE_PRIORITY_CLASS', 'LINUX', 'NETBSD', 'NIC_DUPLEX_FULL', 'NIC_DUPLEX_HALF', 'NIC_DUPLEX_UNKNOWN', 'NORMAL_PRIORITY_CLASS', 'NoSuchProcess', 'OPENBSD', 'OSX', 'POSIX', 'Popen', 'Process', 'REALTIME_PRIORITY_CLASS', 'STATUS_DEAD', 'STATUS_DISK_SLEEP', 'STATUS_IDLE', 'STATUS_LOCKED', 'STATUS_RUNNING', 'STATUS_SLEEPING', 'STATUS_STOPPED', 'STATUS_TRACING_STOP', 'STATUS_WAITING', 'STATUS_WAKING', 'STATUS_ZOMBIE', 'SUNOS', 'TimeoutExpired', 'WINDOWS', 'ZombieProcess', '_PY3', '_TOTAL_PHYMEM', '__all__', '__author__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', '_assert_pid_not_reused', '_common', '_compat', '_last_cpu_times', '_last_cpu_times_2', '_last_per_cpu_times', '_last_per_cpu_times_2', '_pmap', '_process_attrnames', '_psplatform', '_psutil_windows', '_pswindows', '_timer', 'boot_time', 'callable', 'collections', 'cpu_count', 'cpu_percent', 'cpu_stats', 'cpu_times', 'cpu_times_percent', 'disk_io_counters', 'disk_partitions', 'disk_usage', 'errno', 'functools', 'long', 'net_connections', 'net_if_addrs', 'net_if_stats', 'net_io_counters', 'os', 'pid_exists', 'pids', 'process_iter', 'pwd', 'signal', 'subprocess', 'swap_memory', 'sys', 'test', 'time', 'traceback', 'users', 'version_info', 'virtual_memory', 'wait_procs', 'win_service_get', 'win_service_iter']
>>>