2020
09-27
09-27
python中读入二维csv格式的表格方法详解(以元组/列表形式表示)
如何去读取一个没有表头的二维csv文件(如下图所示)?并以元组的形式表现数据:((1.0,0.0,3.0,180.0),(2.0,0.0,2.0,180.0),(3.0,0.0,1.0,180.0),(4.0,0.0,0.0,180.0),(5.0,0.0,3.0,178.0))方法一,使用python内建的数据处理库:#python自带的库rows=open('allnodes.csv','r',encoding='utf-8').readlines()lines=[x.rstrip()forxinrows]#去掉每行数据的/n转义字符lines[0]='1,0,3,180'#手动去掉第一行...
继续阅读 >