2017-08-11 124 views

回答

3

試試這個:

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) 

庫鏈接是here。並退房this

+0

它很好,但我可以得到我的結果:'26%|插入'? –

+0

當然,剛編輯 –

+0

其工作.... –