read input file a line as a list in python

Golawala, Moiz M (GE Infrastructure) Moiz.Golawala at
Tue Aug 17 20:55:38 CEST 2004

oh.. to parse the line that you have into a list you could do this as well.

line = "hello world I am new to python"
lineList = line.split()

#this will get you a list of all the word in the line.

These are basic features of the language. It will serve you well to read the documentation at


-----Original Message-----
From: at
[ at]On Behalf Of
Yong Wang
Sent: Tuesday, August 17, 2004 2:41 PM
To: python-list at
Subject: read input file a line as a list in python

Hi, All:
    I need to read a input file as soucre to process data. Ideally
if I can read a line from input file as a list (coloumn separate by
white space), reorganize field in a line. Does python has this kind of 
command ? 
   for example, I read a line has:
   "IP  MAC Date..." as a line from input file, How  can I only get MAC ?


More information about the Python-list mailing list