Lists and split

Andreas Jung andreas at zope.com
Tue May 7 12:38:20 EDT 2002


http://www.python.org/doc/current/lib/module-urlparse.html

-aj
----- Original Message -----
From: "magni2k" <magni2k at uni.de>
To: <python-list at python.org>
Cc: <666saint at gmx.de>
Sent: Tuesday, May 07, 2002 12:21
Subject: Lists and split


> Hi,
>
> i've got a question about lists and how to split them.
> This little function is not the whole script and my problem depends only
on
> this short lines!
> I want to split an external file into 3 single terms!
> protocol, host, path for example
> The file contains urls in form :
> ftp://home.arcor.de/user/index/
> http://www.python.org/index.html
> ...
> So, what I want is to have a listing in form of:
> ['ftp', 'home.arcor.de', 'user/index']
> ['http', 'www.python.org', 'index.html']
>
>
> def List(self):
>        for line in ListFile(sys.argv[1]):
>            serverlist = string.split(line, '://')
>            print serverlist[1]
>
> Anybody perhaps an idea? The problem is how to split the 2nd time!!
>
> Thanks for everybody who reads and perhaps can help me ;-)
> magni
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list