File operations

John Machin sjmachin at lexicon.net
Fri Aug 22 01:48:40 CEST 2008


On Aug 22, 9:33 am, Gary Herron <gher... at islandtraining.com> wrote:
> aditya shukla wrote:
> > Hello guys
>
> > I am trying to search a file say xyz.txt
>
> > after searching i get the location of the file in
>
> > search_file (containing abspath) ,eg search_file="c:\\abc\\xyz.txt"
>
> > now how should i open this file
>
> > i can use file=open("c:\\abc\\xyz.txt","rb") but i have to use search_
> > file
>
> file=open(search_file,"rb")

and don't use the name of the built-in file function as one of your
own names

and if it's really a text file, don't use "rb", use "r"




More information about the Python-list mailing list