Skip to content

Instantly share code, notes, and snippets.

@tatesuke
Created April 9, 2019 23:29
Show Gist options
  • Select an option

  • Save tatesuke/c3854a0cd299e8ae3b391e8a425639ad to your computer and use it in GitHub Desktop.

Select an option

Save tatesuke/c3854a0cd299e8ae3b391e8a425639ad to your computer and use it in GitHub Desktop.
pythonでPC充電状態を判定
# pip install psutil
# sbattery(percent=100, secsleft=<BatteryTime.POWER_TIME_UNLIMITED: -2>, power_plugged=True)
# sbattery(percent=100, secsleft=4294967295, power_plugged=False)
import psutil
battery = psutil.sensors_battery()
print(battery.power_plugged)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment