[Tutor] cannot find html file, in the same dir as python file

Alan Gauld alan.gauld at yahoo.co.uk
Tue Sep 6 03:43:03 EDT 2016


On 06/09/16 03:18, monikajg at netzero.net wrote:
> I put 
>
> print( os.getcwd() )
>
> into my script, and got 
>
> C:\Users\Monika\Documents\PythonWeb\class3code\class3code

Is that the directory you expected? Is it where your html file lives?

> So I put into my script:
>
> base_url = 'C:\Users\Monika\Documents\PythonWeb\class3code\class3code\button.html' instead of base_url = 'button.html'
> and ran it andI got a popup message in python:
>
> (unicode error) 'unicodesscape' codec can't decode bytes in position 2-3; truncated  \UXXXXXXXXescape

Because you are using a single backslash Python sees the \U as a Unicode
indicator. Either change the backslashes to forward slashes or put an 'r'
in front of the string to make it raw:

base_url = r'C:\Users\Monika\Documents\.....'


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list