Reading a file using a UNC - help!
robert.kern at gmail.com
Tue Sep 26 22:18:04 CEST 2006
richard.kessler at matteicos.com wrote:
> I have the simplest need...to read a file full of file names(unc) and
> then check to see if each of these files exists. I tried with the
> following program, but always get file not found, even when it is
> there. If I type in the file name as a literal it works...
> Little program:
> #This module checks for file existence
> import string
> import sys
> def MainProcess():
> fileList = "c:\a_list_of_filenames.txt"
\ is the escape character in strings, so if you need an actual backslash, you
need to double it:
fileList = "c:\\a_list_of_filenames.txt"
or use "raw" string literals, which don't do any escaping:
fileList = r"c:\a_list_of_filenames.txt"
Please see the tutorial:
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list