Click here to Skip to main content
15,867,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi so I have a file called b2c2.py where I am making a request to return my balances this request returns
b'{"LTC":"0","DOG":"0","USD":"51075.676738623","ADA":"9493.1937","ETH":"3.4E-9","UST":"2977","LNK":"42.422","XLM":"0","GBP":"-58153.761361914","USC":"0.9999995","XRP":"78448.38","EOS":"0","BNB":"0","BTC":"-0.250000004644","EUR":"0.0026082","BCH":"0","DOT":"0","UNI":"0","AUD":"0","CAD":"0","CHF":"0","CNH":"0","ETC":"0","ICP":"0","JPY":"0","KSM":"0","MXN":"0","NZD":"0","SGD":"0","TRX":"0","XAU":"0","XMR":"0","XTZ":"0","ZEC":"0"}'


I then pass this into my views.py called b2c2_response_content and pass it into the context, in my template I am then trying to loop through it to show the balance name and balance holdings in a table. I am unsure on how I can do this for example I want it to display as bitcoin name in a column with its quantity in the column next to it and Ethereum in the row below with its name in one column and its quantity in the next column (not necessarily in that order).

What I have tried:

I did try to loop over it like this to see if I could separate it, by using
{% for x in b2c2_response_content %}{{ x }}{% endfor %}

But this just returns this in the page:
123 34 76 84 67 34 58 34 48 34 44 34 68 79 71 34 58 34 48 34 44 34 85 83 68 34 58 34 53 49 48 55 53 46 54 55 54 55 51 56 54 50 51 34 44 34 65 68 65 34 58 34 57 52 57 51 46 49 57 51 55 34 44 34 69 84 72 34 58 34 51 46 52 69 45 57 34 44 34 85 83 84 34 58 34 50 57 55 55 34 44 34 76 78 75 34 58 34 52 50 46 52 50 50 34 44 34 88 76 77 34 58 34 48 34 44 34 71 66 80 34 58 34 45 48 46 48 48 49 51 54 49 57 49 52 34 44 34 85 83 67 34 58 34 48 46 57 57 57 57 57 57 53 34 44 34 88 82 80 34 58 34 55 56 52 52 56 46 51 56 34 44 34 69 79 83 34 58 34 48 34 44 34 66 78 66 34 58 34 48 34 44 34 66 84 67 34 58 34 45 52 46 54 52 52 69 45 57 34 44 34 69 85 82 34 58 34 48 46 48 48 50 54 48 56 50 34 44 34 66 67 72 34 58 34 48 34 44 34 68 79 84 34 58 34 48 34 44 34 85 78 73 34 58 34 48 34 44 34 65 85 68 34 58 34 48 34 44 34 67 65 68 34 58 34 48 34 44 34 67 72 70 34 58 34 48 34 44 34 67 78 72 34 58 34 48 34 44 34 69 84 67 34 58 34 48 34 44 34 73 67 80 34 58 34 48 34 44 34 74 80 89 34 58 34 48 34 44 34 75 83 77 34 58 34 48 34 44 34 77 88 78 34 58 34 48 34 44 34 78 90 68 34 58 34 48 34 44 34 83 71 68 34 58 34 48 34 44 34 84 82 88 34 58 34 48 34 44 34 88 65 85 34 58 34 48 34 44 34 88 77 82 34 58 34 48 34 44 34 88 84 90 34 58 34 48 34 44 34 90 69 67 34 58 34 48 34 125


Thank you for your help in advance.
Posted
Updated 11-Nov-21 21:35pm

1 solution

The text you are trying to work on is JSON format so you can decode it with the json — JSON encoder and decoder — Python 3.9.8 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900