python: open file, feed line to list, process list data
问题 I want to process the data in the file "output.log" and feed it to graphdata['eth0] I have done this but it process only the first line: logread = open("output.log", "r").readlines() for line in logread: print "line", line i = line.rstrip("\n") b = float(i) colors = [ (0.2, 03, .65), (0.5, 0.7, .1), (.35, .2, .45), ] graphData = {} graphData['eth0'] = [b] cairoplot.dot_line_plot("./blog", graphData, 500, 500, axis=True, grid=True, dots=True, series_colors=colors) 回答1: graphData = {} I believe