how to extract columns like awk $1 $5

Jeremy Sanders jeremy+plusnews at jeremysanders.net
Fri Jan 7 18:38:26 CET 2005


On Fri, 07 Jan 2005 12:15:48 -0500, Anand S Bisen wrote:

> Is there a simple way to extract words speerated by a space in python 
> the way i do it in awk '{print $4 $5}' . I am sure there should be some 
> but i dont know it.

mystr = '1 2 3 4 5 6'
parts = mystr.split()
print parts[3:5]

Jeremy




More information about the Python-list mailing list