[Tutor] Help search files

Alejandro Decchi adecchi at gmail.com
Wed Jul 4 21:14:04 CEST 2007


Ok  but i have this form:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="/cgi-bin/search.py">
  <label><strong> search</strong>
  <input type="text" name="textfield" align="center" />
  </label>
  <p>&nbsp;</p>
  <label><strong>find it</strong>
  <input type="submit" name="Submit" value="Enviar" />
  </label>
  <p>&nbsp;</p>
</form>
</body>
</html>



And i do not how to find the file looking for the user and list the file to
can download it.Can you give me an example ????

Sorry to be a newbie !!!



On 7/4/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> Just set the current directory to the one you want to search using
>
> os.chdir(myPath)
>
> or pass a full path to glob:
>
> glob.glob("/some/path/to/search/*.txt")
>
> HTH,
>
> Alan G.
>
> "Alejandro Decchi" <adecchi at gmail.com> wrote in message
> news:a1885f340707041127j39756c40j256762f6c1350812 at mail.gmail.com...
> > perfect but can you give me a link to find a file in a
> > directory.Because i
> > do not the function to search files in some directory. Can you give
> > an
> > example :
> >
> > On 7/4/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
> >>
> >>
> >> "Alejandro Decchi" <adecchi at gmail.com> wrote
> >>
> >> > Is the word or part of the word that the user enters in the
> >> > texbox .
> >> > And this word is the name of the file to be found
> >>
> >> Ok, In that case use the glob function in the glob module.
> >> It returns a list of all files that match a pattern:
> >>
> >> >>> import glob
> >> >>> files = glob.glob("*.txt")
> >> >>> print files
> >>
> >> For more powerful searches you can use os.walk()
> >>
> >> See the OS topic in my tutorial for more examples of
> >> using glob and os.walk
> >>
> >> HTH,
> >>
> >> --
> >> Alan Gauld
> >> Author of the Learn to Program web site
> >> http://www.freenetpages.co.uk/hp/alan.gauld
> >>
> >>
> >> _______________________________________________
> >> Tutor maillist  -  Tutor at python.org
> >> http://mail.python.org/mailman/listinfo/tutor
> >>
> >
>
>
>
> --------------------------------------------------------------------------------
>
>
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070704/31cffb76/attachment.html 


More information about the Tutor mailing list