file open - Sajha Mobile
SAJHA MOBILE
file open
Posts 3 · Viewed 5409 · Go to Last Post
comingsoon
· Snapshot 0
Like · Likedby · 0
PYTHON HELP
 Dear Computer Scientists and Programmers,
                Let's say there is a directory with several files. I create a list of file name. Now I need to open each file in different condition(or time). In other word I really don't know the file name or it can be changed  any time so how can I code to open the file(s) which is inside the directory?
here is what I did.

import os
L = os.listdir("data")   #data is a folder  <------------- this is fine

file_object = open("data\L[0]","r") <----------- here is the problem



Thank you for your time
and consideration.



Last edited: 22-Apr-13 07:43 PM
Last edited: 22-Apr-13 07:45 PM
Last edited: 22-Apr-13 07:50 PM
Sleepless
· Snapshot 85
Like · Liked by · 0

Check out os.walk()
comingsoon
· Snapshot 330
Like · Liked by · 0
Great! Thanks a lot.
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 19 · Viewed 3074 · Likes 1
· Posts 2 · Viewed 161
· Posts 1 · Viewed 78
· Posts 1 · Viewed 71
· Posts 1 · Viewed 119
· Posts 1 · Viewed 125
· Posts 4 · Viewed 1116
· Posts 1 · Viewed 241
· Posts 1 · Viewed 155
· Posts 1 · Viewed 144



Your Banner Here
Travel Partners
Travel House Nepal