Error in Windows 8 with Unicode

Hi to everyone. I create a Python Script. I run it with Windows 8 an he give to me the message:

“Impossible to translate bytes [E9] at index 0 from specified code page to Unicode.”

The line of the error is:
BackGround =str(mypath+chr(92)+“backgroundimage.png”)

I think it’s the chr(92) is wrong, but i don’t know how i can fix it.

A bad solution maybe can be:
BackGround =str(mypath+"\backgroundimage.png")


Ok, I’m not a Python expert by a long shot, but rather than using your string concatenation, could the following maybe work

import os.path
BackGround = os.path.join(mypath, “backgroundimage.png”)

or use

BackGround = str(mypath + os.sep + “backgroundimage.png”)

You should just be able to use a double backslash:

BackGround =str(mypath+"\\backgroundimage.png")

The first backslash is “escaped”…


or use the string literal “r” notation: r"\backgroundimage.png" in a string literal you don’t have to escape any characters.

combined with the unicode “u” notation, this gets to ur"\backgroundimage.png", a Unicode string literal.

I think this is the best approach since it is completely operating system agnostic.