Home > Mobile >  How can I change a value in a json-like-string with a loop in python 3?
How can I change a value in a json-like-string with a loop in python 3?

Time:07-09

Here is my string:

{"query":"{\"format\":\"article-timeline\",\"from\":**0**,\"isLiveWirePage\":true,\"section\":\"/markets\",\"sections\":\"/markets\",\"size\":6,\"sort\":\"display_date:desc\",\"types\":\"\"}","d":"176","_website":"coindesk"}

CodePudding user response:

counter = 0

for i in range(10): # from 0 to 9
    querystring = '{"query":"{"format":"article-timeline","from":'
    querystring  = str(counter)
    querystring  = ',"isLiveWirePage":true,"section":"/markets","sections":"/markets","size":6,"sort":"display_date:desc","types":""}","d":"176","_website":"coindesk"}'
    counter  = 1

CodePudding user response:

It seems to be a nested dictionary.

querystring = {'query': {'format': 'article-timeline', 'from': 0, 'isLiveWirePage': True, 'section': '/markets', 'sections': '/markets', 'size': 6, 'sort': 'display_date', 'types': ''}, 'd': '176', '_website': 'coindesk'} 



querystring['query']['from'] = 6666666

ResultSet: Click to see image

  • Related