This question already has an answer here:
- Getting Battery Capacity Windows with Python 2 answers
How to get battery percentage with python?
Maybe some win32api
functions may help.
This question already has an answer here:
How to get battery percentage with python?
Maybe some win32api
functions may help.
Try this:
import psutil
battery = psutil.sensors_battery()
plugged = battery.power_plugged
percent = str(battery.percent)
if plugged==False: plugged="Not Plugged In"
else: plugged="Plugged In"
print(percent+'% | '+plugged)
Library link is here. And check out this