Writing to a file

Asked by Eugene

Hi!

There's some problem:

Here is my simpliest script

myLog = open("D:\yyuyuyu\123.txt", "w")
myLog.write("hello!")
myLog.close()

Sikuli doesn't throw any error, but the file is allways empty. What can be wrong?

Thanks.

P.S. Running scrit on Windows XP and Win7-64. Result the same.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

1) Check if path is correct

2) Try to double "\" chars in your path.

myLog = open("C:\\123.txt", "w")
myLog.write("hello!"+"\n")
myLog.close()

- this works for me now.

Revision history for this message
pyCoder (validcode-ye) said :
#2

or

prefix string with "r" raw string

http://www.jython.org/docs/library/re.html#raw-string-notation

myLog = open(r"D:\yyuyuyu\123.txt", "w")

Can you help with this problem?

Provide an answer of your own, or ask Eugene for more information if necessary.

To post a message you must log in.