[Tutor] absolute locations

Ruivaldo Neto ralobao at click21.com.br
Thu Jan 8 19:13:29 EST 2004


Did you try:
file_adress = 'C:\Documents and Settings\Christstopher Spears\My Documents 
python\unit4.txt'
fileobject = open(file_adress,'r')
?

Good luck :)

Em Qui 08 Jan 2004 18:22, Christopher Spears escreveu:
> Grrr!
>
> I'm trying to open up a file with the following
> absloute path in Windows 2000:
>
> C:\Documents and Settings\Christstopher Spears\My
> Documents\python\unit4.txt
>
> So I enter the following in IDLE:
> >>> import os
> >>> fileName = os.path.join("c:", "Documents and
>
> Settings", "Christopher Spears", "My Documents",
> "python", "unit4.txt")
>
> >>> fileobject = open(fileName, 'r')
>
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in -toplevel-
>     fileobject = open(fileName, 'r')
> IOError: [Errno 2] No such file or directory:
> 'c:Documents and Settings\\Christopher Spears\\My
> Documents\\python\\unit4.txt'
>
> I know unit4.txt is there, but I can't seem to
> convince python of that!  What is up with \\ anyway?
>
> =====
> "I'm the last person to pretend that I'm a radio.  I'd rather go out and be
> a color television set." -David Bowie
>
> "Who dares wins"
> -British military motto
>
> "Far more creativity, today, goes into the marketing of products than into
> the products themselves..." -"Pattern Recognition" by William Gibson
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
RS: Ruivaldo Neto




More information about the Tutor mailing list