[Tutor] question
amoreira@mercury.ubi.pt
amoreira@mercury.ubi.pt
Wed, 15 Mar 2000 16:44:17 +0000
Hello!
Try os.path.isdir, as in
for fname in os.listdir(os.curdir)
if os.path.isdir(fname):
print fname+'/'
else:
print fname
This will produce a file listing with directories signalled by a "/" following
their name.
Check the Library Reference sections 6.1 and 6.2 for more info.
Hope it helps!
Ze
Huang John 810-575-1934 wrote:
> Hi, folks,
>
> I am new here. When I use os.listdir(os.curdir) to list the current directory, I
> get a list with the elements being files or subdirectories. My question is how
> to distiguish files from subdirectories. Thanks in advance!
>
> Jun