main.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:coreapi-cli 作者: core-api 项目源码 文件源码
def parse_params(ctx, param, tokens):
    ret = []

    for token in tokens:
        if '=' not in token:
            raise click.BadParameter('Parameter "%s" should be in form of FIELD=VALUE')
        field, value = token.split('=', 1)

        try:
            pair = (field, json.loads(value))
        except:
            if value.startswith('{') or value.startswith('['):
                # Guard against malformed composite objects being treated as strings.
                raise click.BadParameter('Unclear if parameter "%s" should be interperted as a string or data. Use --data or --string instead.' % field)
            pair = (field, value)
        ret.append(pair)

    return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号