first of all, sorry for this easy question. I know these questions are really basic. I need to save a txt file in Python 2.7 with several rows. I need to ask some suggestions to improve my basic code.
this is a basic example
file_out = open("..//example//test.text", "w")
for p in range(10):
ID = str(p)
A = p*10
B = p+10
C = p-10
D = p+p
E = p*2
file_out.write("s% %s %s %s s% s%" % (ID,A,B,C,D,E)+ "\n")
file_out.close()
my question are:
-
i have this Error Message, and i did’n find a way to resolve
Traceback (most recent call last): File "<interactive input>", line 1, in <module> ValueError: incomplete format -
my element to save (ex: ID,A,B,C,D,E) are several (30 elements), and
i use a long line of s%. IS there an elegant way and compact to code
this line?. -
i wish to save also an head (ex: ID,A,B,C,D,E). What is the best way
to do this?
you have a typo
or
or