当前位置: 首页>>代码示例>>Python>>正文


Python CaseInsensitiveDict.setdefault方法代码示例

本文整理汇总了Python中requests.structures.CaseInsensitiveDict.setdefault方法的典型用法代码示例。如果您正苦于以下问题:Python CaseInsensitiveDict.setdefault方法的具体用法?Python CaseInsensitiveDict.setdefault怎么用?Python CaseInsensitiveDict.setdefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在requests.structures.CaseInsensitiveDict的用法示例。


在下文中一共展示了CaseInsensitiveDict.setdefault方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_setdefault

# 需要导入模块: from requests.structures import CaseInsensitiveDict [as 别名]
# 或者: from requests.structures.CaseInsensitiveDict import setdefault [as 别名]
 def test_setdefault(self):
     cid = CaseInsensitiveDict({'Spam': 'blueval'})
     self.assertEqual(
         cid.setdefault('spam', 'notblueval'),
         'blueval'
     )
     self.assertEqual(
         cid.setdefault('notspam', 'notblueval'),
         'notblueval'
     )
开发者ID:k-mito,项目名称:requests-docs-jp,代码行数:12,代码来源:test_requests.py

示例2: _prepare_request

# 需要导入模块: from requests.structures import CaseInsensitiveDict [as 别名]
# 或者: from requests.structures.CaseInsensitiveDict import setdefault [as 别名]
    def _prepare_request(self, command, json=True, opcode_name='command',
                         fetch_list=False, **kwargs):
        params = CaseInsensitiveDict(**kwargs)
        params.update({
            'apiKey': self.key,
            opcode_name: command,
        })
        if json:
            params['response'] = 'json'
        if 'page' in kwargs or fetch_list:
            params.setdefault('pagesize', PAGE_SIZE)
        if 'expires' not in params and self.expiration.total_seconds() >= 0:
            params['signatureVersion'] = '3'
            tz = pytz.utc
            expires = tz.localize(datetime.utcnow() + self.expiration)
            params['expires'] = expires.astimezone(tz).strftime(EXPIRES_FORMAT)

        kind = 'params' if self.method == 'get' else 'data'
        return kind, dict(params.items())
开发者ID:exoscale,项目名称:cs,代码行数:21,代码来源:client.py

示例3: test_setdefault

# 需要导入模块: from requests.structures import CaseInsensitiveDict [as 别名]
# 或者: from requests.structures.CaseInsensitiveDict import setdefault [as 别名]
 def test_setdefault(self):
     cid = CaseInsensitiveDict({"Spam": "blueval"})
     assert cid.setdefault("spam", "notblueval") == "blueval"
     assert cid.setdefault("notspam", "notblueval") == "notblueval"
开发者ID:RRedwards,项目名称:requests,代码行数:6,代码来源:test_requests.py

示例4: test_setdefault

# 需要导入模块: from requests.structures import CaseInsensitiveDict [as 别名]
# 或者: from requests.structures.CaseInsensitiveDict import setdefault [as 别名]
 def test_setdefault(self):
     cid = CaseInsensitiveDict({"Spam": "blueval"})
     self.assertEqual(cid.setdefault("spam", "notblueval"), "blueval")
     self.assertEqual(cid.setdefault("notspam", "notblueval"), "notblueval")
开发者ID:kprantis,项目名称:requests,代码行数:6,代码来源:test_requests.py


注:本文中的requests.structures.CaseInsensitiveDict.setdefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。