想转换的表格
想转换为的二维数组例子
X = [
[0, 0, 128, 0, 0, 82, 0, 0], [0, 0, 128, 0, 0, 82, 0, 0], [0, 0, 128, 0, 0, 82, 0, 0],
[0, 0, 127, 0, 0, 82, 0, 0], [0, 0, 127, 0, 0, 81, 0, 0], [0, 0, 126, 0, 0, 81, 0, 0]
]
X = [
[0, 0, 128, 0, 0, 82, 0, 0], [0, 0, 128, 0, 0, 82, 0, 0], [0, 0, 128, 0, 0, 82, 0, 0],
[0, 0, 127, 0, 0, 82, 0, 0], [0, 0, 127, 0, 0, 81, 0, 0], [0, 0, 126, 0, 0, 81, 0, 0]
]
给个参考,可以的话望采纳,谢谢!
import csv
from re import A
x = []
with open('data.xls ', encoding='utf8') as f:
reader=csv.reader(f) #用csv模块读取f
headers=next(reader) #用next的迭代遍历
#print(headers) #读取csv的头行
for row in reader:
#print(row[0].split('\t'))
data = [int(a) for a in row[0].split('\t')]
#print(data)
x.append(data)
print(x)