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
Check out os.walk()
Sleepless · Apr 22, 2013 8:35 PM
Great! Thanks a lot.
comingsoon · Apr 23, 2013 11:47 PM
This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.
Start a New Discussion