Dec-23-2022, 06:59 AM
Hi,
I'm using code, similar to this:
Thanks.
I'm using code, similar to this:
with open(dbfileA, 'a') as writer: for in_val in userinputs: writer.write("%s" % (in_val)) writer.write("%s" % (comma_t1)) writer.write("%s" % ('\n'))I have 2 questions:
- Do I have to keep using the
%s
format, or is there an easier way?
I've seen websites where they say to just usewriter.write(in_val)
, but that doesn't work.
- How do I close the file after the
with
&for
loop ends?
Does it automatically close? Multiple users will be running this app, & I would like
for the file to close after the program has finished writing the user input to the file.
Thanks.