sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #40027
Re: [Question #374925]: Editing, deleting Files
Question #374925 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/374925
Roman Podolyan posted a new comment:
To manipulate files you need to master OS module:
https://docs.python.org/2/library/os.html
Sorry, I was a bit in a hurry in the morning, and to check working with
files I needed some recalling and code experiment. The code below was
tested on Windows machine with 2016_08_18 nightly:
import sys
# You need sys to manipulate files
print sys.path[0]
# Prints to console the directory script was launched in
f1 = open(sys.path[0] + '\\workfile1.txt', 'w')
f2 = open(sys.path[0] + '\\workfile2.txt', 'w')
# Creates two files, identical except names
f1.write("This is a test N1")
f2.write("This is a test N2")
# Writes a string to every of the created files
f1.close()
f2.close()
# Closes both to remove locking
os.remove(sys.path[0] + '\\workfile2.txt')
# And here we delete the second one, leaving the first intact to show that file creation and writing worked
# "That's all, folks!"
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.