Loading... ```python import xlrd import time p = input('路径') name = input('表的名称是啥就写啥') h = input('产品,价格的行数是多少?') path = xlrd.open_workbook(p) sheet_name = path.sheet_names()[1] sheet = path.sheet_by_name(name) #读取产品名称 c1 = sheet.col_values(0) c1=c1[int(h):-1:1] #读取价格 c2 = sheet.col_values(1) c2=c2[int(h):-1:1] l = [] #开始一一配对 for i in range(len(c1)): if(c1[i] == ''): if (len(l) == 0): print() else: print("最便宜的价格:"+str(min(l))) print("------------------------------") l = [] else: print ("序号:%s 名称:%s 价格:%s" % (i + 1, c1[i], c2[i])) if(isinstance(c2[i],str) or c2[i] == ''): l.append(99999.0) else: l.append(c2[i]) input('Press <Enter> 退出') ``` 这个就是代码 xlsx文件在下面 [1.xlsx](http://blog.a152.top/usr/uploads/2020/08/500858871.xlsx) 这个试验简单试了一下这个python对xlsx文档的一些操作 总的来说就是数据处理 格式按照1.xlsx那个来就行了 Last modification:August 22, 2020 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 如果觉得我的内容对你有用,请随意赞赏