【Python】监控笔记本电池状态
pip install psutil
if __name__ == '__main__': 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)
如果忍耐算是坚强 我选择抵抗 如果妥协算是努力 我选择争取