Sep-21-2021, 02:58 AM
If you want it to be a number, why are you putting it into a list?
On line 20, you are calling
On line 20, you are calling
psutil.cpu_percent()
, which returns a floating point number. But when you put it in brackets, you put that value into a new list.>>> type( psutil.cpu_percent() ) <class 'float'> >>> type( [psutil.cpu_percent()] ) <class 'list'>Take off the brackets and you have a number that you can compare against an integer.
>>> psutil.cpu_percent() 6.3 >>> psutil.cpu_percent() > 90 False