Split Output of Unix who Command (rewho.py) : Split « Regular Expressions « Python Tutorial






from os import popen
import re


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








16.6.Split
16.6.1.with re.split you can split on any sequence of space characters and commas
16.6.2.The maxsplit argument indicates the maximum number of splits allowed:
16.6.3.Split Output of Unix who Command (rewho.py)
16.6.4.Use re package with text file
16.6.5.Regular-expression string manipulation.