[Tutor] problem in opening files
Craig Cesareo
ccesareo at legend3d.com
Sun Jun 24 20:32:15 CEST 2012
Be sure your current working directory is your desktop.
import os
print os.getcwd()
Otherwise specify the full path to the text file. r'c:\users....\mort.txt'
--
Craig Cesareo - iPhone
Pipeline Technical Director
http://www.legend3d.com/
http://www.craigcesareo.com/
609.994.6370
On Jun 24, 2012, at 11:28 AM, "promis at yorku.ca" <promis at yorku.ca> wrote:
> I'm am just new to Python, and am having trouble getting started. I am trying to open files of data that I want to work on, and keep on getting a message that no such file exist. For example here is a copy of what I've typed and the error message
>
>
> >>> fo = open('mort.txt') THIS IS WHAT I TYPED AND THE MESSAGE FOLLOWS
>
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> fo = open('mort.txt')
> IOError: [Errno 2] No such file or directory: 'mort.txt'
>>>>
>
> The file mort.txt certainly seems to me to exist. I can see it on my desktop. It was a small sample file that I just created to test this out. At first I was just using 'mort', which is what appears on my desktop, but it was suggested to me that I should include the extension .txt, which I have verified is the correct extension, so that's not the problem anymore. I have in fact tried this with a number of files and I get the same message every time. I am using Python versus 3.2.2. , on a MAC with system OS 10.6.8 .
>
> Any help would be appreciated
>
> David
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list