As a laptop or PC user, you should be cautious about your battery percent(%) because it is also the most crucial component. That is why we will look at How to Check Battery Percentage of your PC/Laptop Using Python today.
This Python script below can be run in both Windows and Linux.{alertInfo}
Install psutil in windows by :
pip install psutil{codeBox}
Install psutil in Linux by:
sudo apt-get install gcc python3-dev
sudo pip3 install psutil{codeBox}
What is psutil?
psutil is a cross-platform library for retrieving information on running processes and system utilization(CPU, memory, disks, networks, sensors) in Python.
Please find below script:
import psutilbattery = psutil.sensors_battery()percent = str(battery.percent)print("Your device has been running on " + percent +"% battery"){codeBox}
Subscribe our free newsletter for future projects & source code{alertWarning}
Stay updated with Developers Group official social media channels:
0 Comments