headers=self.headers #获取导入模版 file_home = self.import_template log.info(file_home) wb = load_workbook(filename=file_home) ws = wb['sheet1'] # 修改产废单位名称,以及备注 ws['b3'] = 'itest产废单位'+self.dic["t"] ws['s3'] = 'i原料销售'+self.dic["t"] wb.save(file_home) url=self.url_1+"/companies/import?companyType=2" payload={} m=MultipartEncoder( fields={ "parent_dir":'/', "name":'file', "filename":'name.xlsx', 'file':('name.xlsx',open(file_home,'rb'),'application/vnd.ms-excel') } ) headers['Content-Type']=m.content_type r=requests.post(url,headers=headers,data=m) log.info(r.json())