juliolop wrote: ↑Fri Dec 28, 2018 5:51 pm
in every run
I'm trying to rename a file my code always generates in every session in the ending_session function, named report.rep
that name will be replaced with the specific session's WO number to keep records.
what am I doing wrong here?
import os
def ending_session():
CDU.destroy() #close windows
os.rename ('report.rep', %s.rep' % (UUT_wo.get())) #
sys.exit()
What is
UUT_wo? What gets printed if you put the following line between the
os.rename() and
sys.exit() lines? It should be the string that your filename is renamed to sans the extension, if this isn't the string you are expecting then it sounds like UUT_wo contains something other than what you think it should.
Code: Select all
print('UUT_wo.get() returned "{}"'.format(UUT_wo.get()))
Your
os.rename() has a missing quote at the start of the second argument, I take it that is a typo, it's better to cut-and-paste the actual code to avoid typing it in here different to what you are running.