Friday 15 July 2011

Python write to file in list format -


I am trying to write a program that will write a list of information in a text file. Here is an example that I have done so far

  f.open ('blah.txt', 'w') x = input ('put something here') y = input ('something Put info = [x], y, z] a = info [0] b = info [1] c = info [2] f.write (a) f.write (here) b) F.Litat (C) F . However, I need to type it in a list-like format so that I can input  
  x = 1 y = 2 z = 3   

then the file will be read

  1,2,3   

and so the next time I give input information I will write it in a new line

  1,2,3 4,5,6   

How can I fix this?

Format the string and type it:

  s = ', '. Include (info) f.write (s + '\ n')    

No comments:

Post a Comment