我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用urllib.request.parse()。
def dumb_css_parser(data): """returns a hash of css selectors, each of which contains a hash of css attributes""" # remove @import sentences data += ';' importIndex = data.find('@import') while importIndex != -1: data = data[0:importIndex] + data[data.find(';', importIndex) + 1:] importIndex = data.find('@import') # parse the css. reverted from dictionary compehension in order to support older pythons elements = [x.split('{') for x in data.split('}') if '{' in x.strip()] try: elements = dict([(a.strip(), dumb_property_dict(b)) for a, b in elements]) except ValueError: elements = {} # not that important return elements
def dumb_css_parser(data): """returns a hash of css selectors, each of which contains a hash of css attributes""" # remove @import sentences importIndex = data.find('@import') while importIndex != -1: data = data[0:importIndex] + data[data.find(';', importIndex) + 1:] importIndex = data.find('@import') # parse the css. reverted from dictionary compehension in order to support older pythons elements = [x.split('{') for x in data.split('}') if '{' in x.strip()] elements = dict([(a.strip(), dumb_property_dict(b)) for a, b in elements]) return elements