忽略每行的最后一个元素:
with open(waveform, 'rb') as f: reader = csv.reader(f) for row in reader: print row[:-1]
或将每一行转换成字典:
columns = ['value']with open(waveform, 'rb') as f: reader = csv.reader(f) for row in reader: rec = dict(zip(columns, row)) print rec
{'value': '-1'}{'value': '-1'}{'value': '1'}{'value': '1'}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)