Python pyparsing 模块-stringStart() 实例源码

Python pyparsing 模块,stringStart() 实例源码

我们从Python开源项目中,提取了以下1代码示例,用于说明如何使用pyparsing.stringStart()

项目:deb-oslo.utils    作者:openstack    | 项目源码 | 文件源码
def split_by_commas(value):
    """Split values by commas and quotes according to api-wg

    :param value: value to be split

    .. versionadded:: 3.17
    """
    word = (pp.QuotedString(quoteChar='"', escChar='\\')
            | pp.Word(pp.printables, excludeChars='",'))
    grammar = pp.stringStart + pp.delimitedList(word) + pp.stringEnd

    try:
        return list(grammar.parseString(value))
    except pp.ParseException:
        raise ValueError("Invalid value: %s" % value)

相关文章

Python setuptools.dep_util 模块,newer_pairwise_group() ...
Python chainer.utils.type_check 模块,eval() 实例源码 我...
Python chainer.utils.type_check 模块,prod() 实例源码 我...
Python chainer.utils.type_check 模块,expect() 实例源码 ...
Python multiprocessing.managers 模块,BaseProxy() 实例源...
Python multiprocessing.managers 模块,RemoteError() 实例...