read input file a line as a list in python

Golawala, Moiz M (GE Infrastructure) Moiz.Golawala at ge.com
Tue Aug 17 14:55:38 EDT 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 www.python.org

Cheers
Moiz


-----Original Message-----
From: python-list-bounces+moiz.golawala=ge.com at python.org
[mailto:python-list-bounces+moiz.golawala=ge.com at python.org]On Behalf Of
Yong Wang
Sent: Tuesday, August 17, 2004 2:41 PM
To: python-list at python.org
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 ?
    Thanks,

    Yong
 
-- 
http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list