问题
How to get battery percentage with python?
Maybe some win32api
functions may help.
回答1:
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
来源:https://stackoverflow.com/questions/45626937/how-to-get-battery-percentage-with-python