Последнюю версию Python можно найти на http://www.python.org/download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/usr/bin/env python | |
# coding=UTF-8 | |
import math, subprocess | |
p = subprocess.Popen(["ioreg", "-rc", "AppleSmartBattery"], stdout=subprocess.PIPE) | |
output = p.communicate()[0] | |
o_max = [l for l in output.splitlines() if 'MaxCapacity' in l][0] | |
o_cur = [l for l in output.splitlines() if 'CurrentCapacity' in l][0] |
#####Strings
"" #expansion
String.new #constructor
'' #no expansion
%{} #keeps formatting
%q{} #keeps formatting no expansion
%w{a b c} #returns an array of strings no expansion
string = <<EOF #here document
This is the first level of quoting.
This is nested blockquote.
Back to the first level.