我导出列表以使用Python(xlwt)表现出色:response = HttpResponse(mimetype="application/ms-excel")response['Content-Disposition'] = 'attachment; filename=MyList.xls'wb = xlwt.Workbook()ws = wb.add_sheet('my_list')ws.write(0, 0, 'Country ID')if var =='with_flag': ws.write(0, X, 'Country Flag')ws.write(0, 1, 'Country Name')如果我出口时不带标志,则出口通过了镍;),但是问题是当我选择带标志时出口。我应该尊重列(1- country_name,2- country_flag,3- country_id)的顺序。我知道Python不支持++。X在我的代码中是否有任何条件可以按特定顺序进行导出?
1 回答

小唯快跑啊
TA贡献1863条经验 获得超2个赞
如果我正确理解您的问题,则您需要以下内容:
X = 1
if var =='with_flag':
ws.write(0, X, 'Country Flag')
X += 1
ws.write(0, X, 'Country Name')
添加回答
举报
0/150
提交
取消