Search code examples
python-3.xpython-requestspython-re

Extract numbers from response in python3


when i send request to the server i will receive this response

{"SUBMIT_FLAG":1,"BALANCE":"  412000  "}

how can i extract just last numbers 412000 this is numbers its variable and sorry for my bad language thanks in advance


Solution

  • You can use the json module like this:

    import json
    
    data = """
    {"SUBMIT_FLAG":1,"BALANCE":"  412000  "}
    """
    
    json_data = json.loads(data)
    
    print(json_data['BALANCE'])
    
    

    Output

    412000