Re: os.listdir(<file specifications>) doesn't work ??
- From: "timw.google" <tjandacw@xxxxxxxxx>
- Date: 14 May 2007 13:18:01 -0700
On May 14, 4:09 pm, Stef Mientki <S.Mientki-nos...@xxxxxxxxxxxxxx>
wrote:
hello,
I want to find all files with the extension "*.txt".
From the examples in "Learning Python, Lutz and Asher" and
from the website I see examples where you also may specify a wildcard filegroup.
But when I try this
files = os.listdir('D:\\akto_yk\\yk_controle\\*.txt')
I get an error message
WindowsError: [Errno 123] The filename, directory name, or volume label syntax is incorrect:
'D:\\akto_yk\\yk_controle\\*.txt/*.*'
What am I doing wrong ?
thanks,
Stef Mientki
You want the glob module
http://docs.python.org/lib/module-glob.html
import glob
glob.glob('*.txt')
.
- Follow-Ups:
- Re: os.listdir(<file specifications>) doesn't work ??
- From: Stef Mientki
- Re: os.listdir(<file specifications>) doesn't work ??
- From: Michel Claveau
- Re: os.listdir(<file specifications>) doesn't work ??
- References:
- os.listdir(<file specifications>) doesn't work ??
- From: Stef Mientki
- os.listdir(<file specifications>) doesn't work ??
- Prev by Date: Re: Bug? import cp1252
- Next by Date: Re: Simulating simple electric circuits
- Previous by thread: os.listdir(<file specifications>) doesn't work ??
- Next by thread: Re: os.listdir(<file specifications>) doesn't work ??
- Index(es):
Relevant Pages
|