Creating a file to write in python -
pardon me silly newbie question, create/open file writing compiler error.
tmp1 = os.path.join(self.vardirname.get(), strftime("%y_%m_%d")+'_errs') tmp2 = os.path.join(tmp1,mysubfolder) if not os.path.exists(tmp2): os.makedirs(tmp2) fn = os.path.join(tmp2,'hello.txt') f = file(fn, "w") #i tried this: fna = os.path.join(tmp2,'hello.txt') fn = "hello.txt" f = open(fn, "w")
error in last line: nameerror: name 'fn' not defined, if hardcode filename, creates it. how create variable name?
Comments
Post a Comment