zoukankan      html  css  js  c++  java
  • Python接口测试-以&连接拼接字典数据(get中url请求数据)

    get请求的utl数据是这样的,例如:/banner/findBanner?bannerType=1&_=1556107073181

    '''
    1-banner图-banner/findBanner
    '''
    str1=parse.urlencode(data1)
    url1='{0}/banner/findBanner?bannerType=1&_=1556107073181'.format(yuming)
    headers ={'Content-Type':'application/json;charset=UTF-8',
              'Accept':'application/json, text/javascript, */*; q=0.01',
              'Referer':'{0}/'.format(yuming)}
    r=requests.get(url=url1,headers=headers)
    repones=r.text
    print('*'*100,'
    ','1-banner图-banner/findBanner','
    ','*'*100)
    print()
    print(r.status_code)
    print(r.text)

    如果参数比较多的话如何自动拼接呢

    from urllib import parse
    
    '''
    1-banner图-banner/findBanner
    '''
    data1={
        'bannerType':1,
        '_':1556107073181
    }
    str1=parse.urlencode(data1)
    url1='{0}/banner/findBanner?{1}'.format(yuming,str1)
    headers ={'Content-Type':'application/json;charset=UTF-8',
              'Accept':'application/json, text/javascript, */*; q=0.01',
              'Referer':'{0}/'.format(yuming)}
    r=requests.get(url=url1,headers=headers)
    repones=r.text
    print('*'*100,'
    ','1-banner图-banner/findBanner','
    ','*'*100)
    print()
    print(r.status_code)
    print(r.text)
  • 相关阅读:
    微软下载
    stsadm.exe
    将表数据生成Insert脚本
    silverlight客户端保存文件乱码问题
    MySql全文索引
    SQL 自增主键从1开始
    Redis 数据结构之简单动态字符串SDS
    vs2012升级到vs2013后,sql server 无法通过IP登录解决方案
    常见XSD问题
    EntitySpace 常用语句
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/10819132.html
Copyright © 2011-2022 走看看