import xlwt
book = xlwt.Workbook(encoding='utf-8',style_compression=0)
sheet = book.add_sheet('testsheet',cell_overwrite_ok=True)
col = ('库位编码','货架编码')
for f in range(0,2):
sheet.write(0,f,col[f])
li = ['HAI-001-001-01','HAI-001-001-02','HAI-001-001-03']
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19,20]
n = int(input('请输入n:'))
list_a = [lists[i:i+n] for i in range(0, len(lists), n)]
print(list_a)
res = dict(zip(li,list_a))
for i,val in res.items():
print(i,val)
for j in val:
sheet.write(j, 0, str(i))
sheet.write(j, 1, 'bin' + str(i))
book.save('test.xls')