Notez les extraits de code fréquemment utilisés.
PowerShell
PS> Get-Process -Name powershell | Format-List -Property ProcessName,FileVersion
,StartTime,Id
ProcessName : powershell
FileVersion : 1.0.9567.1
StartTime : 2006-05-24 13:42:00
Id : 2760
ProcessName : powershell
FileVersion : 1.0.9567.1
StartTime : 2006-05-24 13:54:28
Id : 3448
Python
import re
ps_result = '''
ProcessName : powershell
FileVersion : 1.0.9567.1
StartTime : 2006-05-24 13:42:00
Id : 2760
ProcessName : powershell
FileVersion : 1.0.9567.1
StartTime : 2006-05-24 13:54:28
Id : 3448
'''
lines = ps_result.split('\n')
dics = []
dic = {}
for line in lines:
ret = line.split(' : ')
if len(ret) == 2:
ret[0] = re.sub(r' +$', '', ret[0])
dic[ret[0]] = ret[1]
if dic != {} and len(ret) < 2:
dics.append(dic)
dic = {}
print dics
http://millfont.blogspot.jp/2011/08/pythoncsv.html
https://technet.microsoft.com/ja-jp/library/dd347677.aspx
Recommended Posts