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)
import xlrd
table = xlrd.open_workbook('data.xls')
sheet = table.sheet_by_name('sheet')
rows = sheet.nrows # 获取行数
cols = sheet.ncols # 获取列数
all_content = []
a = []
for i in range(0, rows):
for j in range(0, cols):
cell_value = sheet.cell(i, j).value
a.append(cell_value)
print("a:", a)
a = []
all_content.append(a)
all_content.remove([])
print(all_content)