以脚本执行不会直接从shell返回任何值,而是返回0.0
操作系统:CentOS 7.6.1810
我在提示符下尝试过
Installing psutil…
✔ Installation Succeeded
Installing dependencies from Pipfile.lock (9ac545)…
▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:06
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
# pipenv run python main.py
test
# cat main.py
#!/usr/bin/env python
import psutil
# gives a single float value
psutil.cpu_times_percent(1)
psutil.cpu_count()
print("test")
# pipenv shell
Launching subshell in virtual environment…
. /root/.local/share/virtualenvs/CPULoad-nZABaO0t/bin/activate
# . /root/.local/share/virtualenvs/CPULoad-nZABaO0t/bin/activate
# python
Python 3.6.8 (default, Apr 25 2019, 21:02:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.cpu_times_percent(1)
scputimes(user=0.0, nice=0.0, system=0.0, idle=100.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
我期望与python提示符相同的结果。任何帮助表示赞赏。