import xlrd as xd
data =xd.open_workbook ('豆瓣电影数据.xls') #打开excel表所在路径
sheet = data.sheet_by_name('豆瓣电影数据') #读取数据,以excel表名来打开
d1 = []
for r in range(sheet.nrows): #将表中数据按行逐步添加到列表中,最后转换为list结构
data1 = []
for c in range(sheet.ncols):
data1.append(sheet.cell_value(r,c))
d1.append([i for i in data1 if i and i !=''])
print(d1)
望采纳
import xlrd as xd
data =xd.open_workbook ('豆瓣电影数据.xls') #打开excel表所在路径
sheet = data.sheet_by_name('豆瓣电影数据') #读取数据,以excel表名来打开
d1 = []
for r in range(sheet.nrows): #将表中数据按行逐步添加到列表中,最后转换为list结构
data1 = []
for c in range(sheet.ncols):
data1.append(sheet.cell_value(r,c))
d1.append([i for i in data1 if i and i !=''])
for item in d1:
item[0] = int(item[0])
item[2] = int(item[2])
print(d1)