def get_all(content, keyword): keys = [] values = [] for specs in keyword: num = keyword.index(specs) keys.append(specs) if num <= len(keyword) - 2: values.append(keyword[num + 1]) else: pass spec_data = dict(zip(keys, values)) if content in spec_data: brand = ''.join(spec_data[f'{content}']).replace(f'{content}', '') else: brand = '暂无' return brand
标签:keyword,keys,列表,JSON,num,取值,specs From: https://www.cnblogs.com/wolvies/p/17828444.html