Based on your question, it looks like you have a list of URLs separated by new lines. In that case you can use a for
loop to iterate over them:
list_pathlist = []for url in dat.split('\n'): parsed = urlparse(url) path = parsed[2] #defining after www.foo.com/ pathlist = path.split("/") list_pathlist.append(pathlist)
In which case I suspect the result (list_pathlist
) will be something like:
[['', '2016', '01', '0124'],['', '2016', '02', '1222'],...]
so a list of lists.
Or you can put it into a nice one-liner using list-comprehension:
list_pathlist = [urlparse(url)[2].split('/') for url in dat.split('\n')]