我是Python新手。我已经生成了由24个数字组成的3个数字组合(总组合2024)。我的目的是将这些组合放在同一工作簿的不同excel表格中。例如,每张图纸中有100个组合。我从这个网站上得到了一些参考资料,并尝试使用它。但是,所有的组合仍然在同一张表中生成
import xlsxwriter
workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet()
import itertools as it
combin = it.combinations(range(1,25),3)
count_combin = []
for i in combin:
count_combin.append(i)
max_row = 100
row_num = 0
for data in count_combin:
if row_num == max_row:
worksheet = workbook.add_worksheet()
row_num = 0
for row, group in enumerate(count_combin):
for col in range(3):
worksheet.write (row, col, group[col])
row_num += 1
workbook.close()
请告诉我编码有什么问题?
这应该可以做到(在代码注释中解释)
相关问题 更多 >
编程相关推荐