Read a group of files as a list

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Mon Sep 18 20:27:05 EDT 2006


citlaly:
> I'm trying to use the files from a
> "folder" as a list. What I want to do is  read each one as a list, but
> just the name of the file, the data inside doesn't matter.

>>> import os
>>> os.listdir("...path...")
[.... file names... ]

If you are using Windows I suggest you to invert the slashes of the
path, so instead of:
"C:\WINNT\Fonts"
Use:
"C:/WINNT/Fonts"

Bye,
bearophile




More information about the Python-list mailing list