尝试下载带有通过python 2.7更改的变量的报表时出错

时间:2017-06-15 17:52:20

标签: python-2.7

错误:无法连接'str'和'int'对象

尝试从我们的qualys漏洞扫描程序自动下载报告,但由于变量是整数而不是字符串,我收到错误,我知道我需要做str(变量)名称,但它没有'工作

newreportID在第8行抛出错误,错误高于

def downloadReport(s, newreportID):
    # ---Download reports---
    payload = {
                'action':'fetch',
                'id': newreportID,
        }
    r = s.post('https://qualysapi.qg2.apps.qualys.com:443/api/2.0/fo/report/', data=payload)
    with open("Z:/Shared/Scan_Report_"+ newreportID +".csv", "wb") as report:
        report.write(r.content)

def main(newreportID):
    s = requests.Session()
    s.headers.update({'X-Requested-With':'Facklers PyQual python primer'})
    login(s)
    listReports(s, newreportID)
    downloadReport(s, newreportID)
    logout(s)
    s.close()

if __name__ == "__main__": main(newreportID)

0 个答案:

没有答案