sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #12883
Re: [Question #207537]: Quick question, creating log file
Question #207537 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/207537
Status: Open => Answered
RaiMan proposed the following answer:
the created filename should be something like
D:\Games2012124513.txt
because the \ is missing
I usually use os.path.join() to create valid filenames (no need for \ )
import datetime
import os
dir = "D:\\Games"
Filename = datetime.datetime.now().strftime("%Y%H%M%S.txt") #sets the filename
log = file(os.path.join(dir, Filename), "w") #create the file
log.close() # close the file/handles to the file.
--- comments
since time is already imported, the same result but shorter:
Filename = time.strftime("%Y%H%M%S.txt")
time() gives you a granularity of millisecs for automatic unique filenames
Filename = str(int(time.time()*1000))
my final version:
import os
dir = "D:\\Games"
Filename = str(int(time.time()*1000)) #sets the filename
log = file(os.path.join(dir, Filename), "w") #create the file
log.close() # close the file/handles to the file.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.