← 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

furni gave more information on the question:
like you said before,  u and .encode("utf-8") of  data =
u"C:\\Users\\aaaaa\\Desktop\\依頼文\\sikuli_funcあ.txt".encode("utf-8")
weren't needed

#########
import os
import sys
import codecs
#data = u"C:\\Users\\aaaaa\\Desktop\\依頼文\\sikuli_funcあ.txt".encode("utf-8")
data = "C:\\Users\\aaaaa\\Desktop\\依頼文\\sikuli_funcあ.txt"
print data
dir = os.path.dirname(data)
uprint("*** content of " + dir)
for fname in os.listdir(unicode(dir,"utf-8")):
  uprint(fname)
uprint("*** content of " + data)
for line in codecs.open(data,"r","shift_jis"):
    print line.encode("utf-8")
#########
print out 
#########

C:\Users\aaaaa\Desktop\依頼文\sikuli_funcあ.txt
*** content of C:\Users\aaaaa\Desktop\依頼文
FIRST.sikuli
FORTH.sikuli
SECOND.sikuli
sikuli_funcあ.txt
THIRD.sikuli
新しいテキスト ドキュメント - コピー (2).txt
新しいテキスト ドキュメント - コピー (3).txt
新しいテキスト ドキュメント - コピー (4).txt
新しいテキスト ドキュメント - コピー.txt
新しいテキスト ドキュメント.txt
*** content of C:\Users\aaaaa\Desktop\依頼文\sikuli_funcあ.txt
#########

when writing the script below ..
#########
#coding: utf-8
print [u"こんにちは"]
print [u"こんにちは".encode("utf-8")]
print ["こんにちは"]
#########
i get this
#########

[u'\u3053\u3093\u306b\u3061\u306f']
['\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf']
['\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf']

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