How to read a directory path from a txt file
Rustom Mody
rustompmody at gmail.com
Mon Jun 2 10:28:34 EDT 2014
On Monday, June 2, 2014 7:48:25 PM UTC+5:30, Samuel Kamau wrote:
> I have created a txt file with various paths to directories. The paths look like this
>
> /home/wachkama/Desktop/api/genshi
>
> /home/wachkama/Desktop/www/portal/schedule
>
> /home/wachkama/Desktop/show/help.genshi
>
>
>
> How do i read this paths in python ?
for x in open("filenames.txt"):
print x
Assuming your filenames are in a file called filenames.txt in current directory
Also in practice:
1. You probably want print x.strip()
2. You dont want a print but whatever is the code you want
More information about the Python-list
mailing list