← Back to Kurakani

file open

Original Post

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

comingsoon
Apr 22, 2013 7:42 PM · 13,600 views
2 Replies
Sleepless Apr 22, 2013 8:35 PM
Check out os.walk()
comingsoon Apr 23, 2013 11:47 PM
Great! Thanks a lot.
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
  • ✓Everest Solar Solar Services
    Woburn, MA · · 864 views
  • Kathmandu · · 1,234 views
  • Base Camp Restaurant
    San Francisco, CA · · 516 views
  • Bini's Kitchen LLC Restaurant
    San Francisco, CA · · 501 views
  • Bir Kitchen Restaurant
    San Francisco, CA · · 495 views
Ask Sajha AI Assistant