How to only get a list of the names of the non-directory files in current directory ('.')?

iMath redstone-cold at 163.com
Wed Nov 7 00:12:46 CET 2012


在 2012年11月6日星期二UTC+8下午1时24分41秒,Chris Angelico写道:
> On Tue, Nov 6, 2012 at 4:19 PM, iMath <redstone-cold at 163.com> wrote:
> 
> > How to only get a list of the names of the non-directory files in current directory ('.')?
> 
> > (Note excluding its subdirectories ).
> 
> >
> 
> > I need the code : )
> 
> 
> 
> Start by getting a list of names of everything in the current directory.
> 
> 
> 
> Then filter that list by testing each one to see if it's a directory.
> 
> 
> 
> Tip: The second step can be done with os.path.isdir
> 
> 
> 
> Put some code together and try it. If you have trouble, post your
> 
> code, any exception traceback you get, and what you're having
> 
> difficulty with, and we'll go on from there.
> 
> 
> 
> Have fun!
> 
> 
> 
> ChrisA

how to get a list of names of everything in the current directory ?


More information about the Python-list mailing list