regex - How do I JSON_encode a dictionary in python? -
value = re.findall(b,'some regex',respdata) keywords = re.findall(b,'some regex',respdata) #empty dictionary dictionary = {} x=0 eachvalue in value: dictionary[eachvalue] = keyword[x] x+=1 print(dictionary)
after this, want json encode dictionary in "value:keyword" format, suggestions on how this? thank in advance
python has module json
:
value = re.findall('some regex',respdata) keywords = re.findall('some regex',respdata) print json.dumps(dict(zip(value, keywords)))
Comments
Post a Comment