Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

show battery of my laptop python

# python script showing battery details
import psutil
  
# function returning time in hh:mm:ss
def convertTime(seconds):
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    return "%d:%02d:%02d" % (hours, minutes, seconds)
  
# returns a tuple
battery = psutil.sensors_battery()
  
print("Battery percentage : ", battery.percent)
print("Power plugged in : ", battery.power_plugged)
  
# converting seconds to hh:mm:ss
print("Battery left : ", convertTime(battery.secsleft))
Comment

PREVIOUS NEXT
Code Example
Python :: python read requests response 
Python :: how to make random colors in python turtle 
Python :: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. 
Python :: openpyxl xls 
Python :: telnet python 
Python :: ValueError: Shapes (None, 1) and (None, 11) are incompatible keras 
Python :: get columns containing string 
Python :: Network.py socket 
Python :: find index of pandas column 
Python :: accessing dictionary elements in python 
Python :: percentage of null values for every variable in dataframe 
Python :: make new app folder in django templates dir 
Python :: find first date python 
Python :: isinstance float or int 
Python :: pandas dataframe select last n columns 
Python :: check if float is integer python 
Python :: ipython read audio file 
Python :: python string to datetime 
Python :: sort dictionary 
Python :: python3 hello world 
Python :: how to import pygame 
Python :: colab add package 
Python :: how to veiw and edit files with python 
Python :: python data frame check if any nan value present 
Python :: how to create a role and give it to the author discord.py 
Python :: tofixed in python 
Python :: python get duration of wav file 
Python :: euclidean division in python 
Python :: python csv 
Python :: public in python 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =