[Show all top banners]

Replies to this thread:

More by comingsoon
What people are reading
:: Subscribe
Back to: Kurakani General Discussion Refresh page to view new replies
 file open
SAVE! for ease of future access.
Posted on 04-22-13 7:42 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?        

 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

Posted on 04-22-13 8:35 PM     [Snapshot: 85]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        

Check out os.walk()

Posted on 04-23-13 11:47 PM     [Snapshot: 330]     Reply [Subscribe]
Login in to Rate this Post:     0       ?        

Great! Thanks a lot.

Please Log in! to be able to reply! If you don't have a login, please register here.



Within last 7 days
Recommended Popular Threads Controvertial Threads
बिहे गर्न अगाडी प्रियांकाले आफ्ना शुभेक्छुकहरुलाई यसरी आफ्नो पोल्ने धुंवादार शरीर (smoking hot body) देखाईन
How to Apply for International Drivers Permit in Nepal?
is it good to marry girl who are already in US or go back to Nepal and do arrange marriage?
थुतुनो र मुतुनो ठिक ठाउँमा भएन भने life damage !!!
अब नसुध्रि शुख - आस्था राउतले डण्ठे भन्दै गालि नगरेको भए कसैले सुन्थेन ....
Nepalese Man Sentenced on Marriage Fraud Charges
Question on getting advance parole for tps holder.
W2 issue
Presidential rights to assassination rights?
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters