Posted by: comingsoon April 22, 2013
Login in to Rate this Post:
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.
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