Write list of tuples to txt file
问题 Consider this list of tuples: list=[((0.0, 0.0), (0.00249999994412065, -509.707885742188), (0.00499999988824129, -1017.52648925781), (0.0087500000372529, -1778.51281738281), (0.0143750002607703, -2918.21899414063), (0.0228125005960464, -4609.91650390625))] I'd like to write the information to a txt file in this format: 0.0 0.0 0.00249999994412065 -509.707885742188 .... I've been using this code: with open(fname, 'w') as graphd: for row in list: print >>graphd, ', '.join(map(str, row)) graphd