← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #272186]: double backslashes in printed strings --- is by convention (a \ must be escaped with a \ )

 

Question #272186 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/272186

    Status: Answered => Open

furni is still having a problem:
Thanks for answering, Raiman!
>The double \ are only in the printout (according to the need to escape a \ with the escape character \). I guess this is to be >prepared for copy&paste. The strings themself internally are correct.
>
>why do you think, you need that?
 
 
 
I'm really new to Sikuli or python, and thought the backslash was mandatory.
 
 
 
>path1 = u"Users\\system99\\Desktop\\sikuli_func.txt".encode("utf-8")
>path1 = r"Users\system99\Desktop\sikuli_func.txt"
>should be sufficient.
>
>your problem:
>[error] IOError ( (2, 'No such file or directory', 'Users\\system99\\Desktop\\sikuli_func.txt') )
>
>a relative path is looked for in the current working directory, but I guess you mean:
>path1 = r"c:\Users\system99\Desktop\sikuli_func.txt"
 
I changed the path1 to path1 = r"c:\Users\system99\Desktop\sikuli_func.txt", and that prblem was solved .
But when there are chinese characters in the path, still get an error. :((

###########################
import sys
import codecs
path1 = u"D:\\依頼分\\sikuli.funcあ.txt".encode("utf-8")
print path1
for list in codecs.open(path1,"r","shift_jis"):
    print list.encode("utf-8")
###########################

and i get the error below

###########################
D:\依頼分\sikuli.funcあ.txt
[error] script [ temp6 ] stopped with error in line 5
[error] IOError ( (2, 'No such file or directory', 'D:\\\xe4\xbe\x9d\xe9\xa0\xbc\xe5\x88\x86\\sikuli.func\xe3\x81\x82.txt') )
[error] --- Traceback --- error source first line: module ( function ) statement 881: codecs ( open ) IOError: (2, 'No such file or directory', 'D:\\\xe4\xbe\x9d\xe9\xa0\xbc\xe5\x88\x86\\sikuli.func\xe3\x81\x82.txt')
[error] --- Traceback --- end --------------

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.