[Tutor] Python 3.4.1 question for Mac users
Chris “Kwpolska” Warrick
kwpolska at gmail.com
Fri Aug 29 18:39:49 CEST 2014
Sorry for the errorneous quote-only response, gmail managed to send it
without me typing a thing.
On Fri, Aug 29, 2014 at 5:01 PM, Richard Dillon <dillonrw at comcast.net> wrote:
> infile = open(r'\OS\Users\richarddillon\Desktop\my_file','r')
On the Mac, you don’t need to specify a drive there; the main drive is just /.
Also, the path separator is a forward slash (/). This also lets you
remove the r in front of the string, which is needed for backslashes
unless you escape them. The corrected code is:
infile = open('/Users/richarddillon/Desktop/my_file', 'r')
--
Chris “Kwpolska” Warrick <http://chriswarrick.com/>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
More information about the Tutor
mailing list