Mega Code Archive

 
Categories / Python Tutorial / Regular Expressions
 

Split Output of Unix who Command (rewho py)

from os  import popen import re f = popen('who', 'r') for eachLine in f.readlines():    print split('\s\s+|\t', eachLine.strip()) f.close()