Get Laptop Battery Percentage Using Python

Get Laptop Battery Percentage Using Python

  • We are gonna use psutil python module to do this task. psutil (process and system utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python.
  • It is useful mainly for system monitoring, profiling, and limiting process resources and management of running processes. It implements many functionalities offered by classic UNIX command-line tools such as ps, top, iotop, lsof, netstat, ifconfig, free and others. psutil currently supports the following platforms:
  1. Linux
  2. Windows
  3. macOS
  4. FreeBSD, OpenBSD, NetBSD
  5. Sun Solaris
  6. AIX

Installation:- 

Code: 


Output:





Comments