我導(dǎo)出列表以使用Python(xlwt)表現(xiàn)出色: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')如果我出口時(shí)不帶標(biāo)志,則出口通過了鎳;),但是問題是當(dāng)我選擇帶標(biāo)志時(shí)出口。我應(yīng)該尊重列(1- country_name,2- country_flag,3- country_id)的順序。我知道Python不支持++。X在我的代碼中是否有任何條件可以按特定順序進(jìn)行導(dǎo)出?
1 回答

小唯快跑啊
TA貢獻(xiàn)1863條經(jīng)驗(yàn) 獲得超2個(gè)贊
如果我正確理解您的問題,則您需要以下內(nèi)容:
X = 1
if var =='with_flag':
ws.write(0, X, 'Country Flag')
X += 1
ws.write(0, X, 'Country Name')
添加回答
舉報(bào)
0/150
提交
取消