python - Formatting output when writing a list to textfile -


I have a list of lists that look like this:

  dupe = [ [95d1543adea47e88923c3d4ad56e9f65c2b40c76 ',' ron \\ c ',' apa.txt '], [' 95d1543adea47e88923c3d4ad56e9f65c2b40c76 ',' ron \\ c ',' knark.txt '], [' b5cc17d3a35877ca8b76f0b2e07497039c250696 ',' Ron \ 'a, Apa 2 .txt '], [' b5cc17d3a35877ca8b76f0b2e07497039c250696 ',' ron \\ a ',' jude.txt ']]  

I use this one very basic function () Write on file: Try

 : file_name = open ("dupe.txt", "W") except for IOError: passed for one in range (Lane (victim)): file_name .write (Cheat [a] [0] + "" + betrayal [a] [1] + "" + betrayal [a] [2] + "\ n"); File_name.close ()  

The file is looking like this:

  95d1543adea47e88923c3d4ad56e9f65c2b40c76 Ron \ c apa.txt 95d1543adea47e88923c3d4ad56e9f65c2b40c76 Ron \ c knark.txt B5cc17d3a35877ca8b76f0b2e374359c250696 However, how can I output to dupe.txt file to look like this:  
 

95d1543adea47e88923c3d4ad56e9f65c2b40c76 ron \ c apa.txt, knark.txt b5cc17d3a35877ca8b76f0b2e07497039c250696 ron \ a apa2.txt, jude.txt

  dupedict = {} a, b, c for cheating: dupedict.setdefault ((a, b), []) .andend (c)  

then print it:

for the key, in the value Dupedict.iteritems (): Print '' .joy (key), ',' .join (value)

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -