[Tutor] Python 3.4.1 question for Mac users

Richard Dillon dillonrw at comcast.net
Fri Aug 29 17:01:17 CEST 2014


I’m teaching myself Python 3.4.1 on a Mac and the book I’m using is written for Windows users.

I’m trying to open a file on the desktop and I created a path using the  example in the book.

 

Any Mac users out there with a solution? My main drive is named “OS”.

Here’s my code:


  

def main():

    my_file = input('Enter file to open: ')

    infile = open(r'\OS\Users\richarddillon\Desktop\my_file','r')

    file_contents = infile.read()

    infile.close()

    print(file.contents)

 

main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140829/c2b3203a/attachment.html>


More information about the Tutor mailing list