How to get battery percentage with python?
Maybe some win32api
functions may help.
Just swipe down from the top-right corner of your display. With iOS 16, you can turn on the battery percentage so it appears in your status bar. Go to Settings > Battery, and turn on Battery Percentage.
Try this:
import psutil
battery = psutil.sensors_battery()
plugged = battery.power_plugged
percent = str(battery.percent)
plugged = "Plugged In" if plugged else "Not Plugged In"
print(percent+'% | '+plugged)
Library link is here. And check out this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With