create account

Python Libraries: Simple... Display your Splinterlands DEC by slobberchops

View this thread on: hive.blogpeakd.comecency.com
· @slobberchops ·
$103.89
Python Libraries: Simple... Display your Splinterlands DEC
![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swigvWKHx2p6RcKVsHRYkxBKBi9R4swCbxPL8cv46RzBUGaPAzVWYgPUfC39YUrEZqa.png)

In an attempt to write something ‘useful’ without stealing it from the internet I set about trying out the Splinterlands API for the first time.

There are scripts on GitHub that do a lot more than what I show you here, but lifting them won't teach you Python.

You need to write them from nothing and without looking if you want it all to sink in.

<center>
![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23zkbfDfmRmdyMkoXYTQncNa59ssfY1NL8ZJ1nNncUNN4bPrv7uhPZ7QvqbjDFWcnNpLQ.png)
...***'the output after running this script, it displays the data I am looking for and nothing else'...***
</center>

I have **SEVEN** Splinterlands accounts that are DEC collectors. You read that correctly, it’s unrelated to tax collecting and DEC is one of the native Splinterlands tokens.

I realise this is unusual but can imagine some players/investors have more than a single account. To check quickly on the status of my accounts, I wanted to have a desktop shortcut I could click to reveal my balances.

It couldn’t be that hard surely?

Using the Splinterlands API was merely a call using a variable to pipe the data into.

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swiP3uYksZShMMmceAc9Qaz3grvrcxh3KjuvghF6koP9WuyuXzfBJLUckDNYuNtJBiG.png)

Nice and easy but the URL variable held a lot more than just my DEC totals and I needed to suffix the call with my account. That’s what the + is for.

As there are **SEVEN** of them, it made sense to use of a List data structure and further down the script use a For loop to cycle through them.

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swibVytFW2kgSbTGBhzvvahAc286PpkE1of1tK1WvXnagoni3j98BRCSmkVZCkET7gv.png)

I noted the data being filtered into the 'url' variable appeared to be formatted but occasionally contained strange characters.

Being intent on mastering this myself, I tried several ways to separate the data into something more readable and eventually came to the conclusion it was json data.


![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23t77B9E8yEVdZ2hPL7QdNzxNaKvx6hpKMFK7VSvtsS3AK8YBrs9BbCW2HQp9wwybLqJ4.png)


This did the trick and now I could interrogate it correctly. To utilise the json.loads method, python requires a couple of libraries to be accessible.

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swiJgS1GyqHSYuum2qfmoiiS5XJmTgTJAxUSbdskKcoEtBJQELsiazVictseKv65biM.png)

Simply add these at the top of your script.

Now I had some readable data to work with, I needed another loop with an embedded If statement within it to get at the DEC data.

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swiNxYVGQfjnH1JGgvDqxt9AJWc7bccc58MmZJU3EvyHqwCy63gP3iUDNVoHuUehChg.png)

data[‘player’] and data [‘balance’] were what I needed to display in some readable form. The issue was that my account names within the data['player'] variable were all of different lengths.

Simply printing them to the console was displaying it but not in the neat straight lines I wanted.

Some padding was needed and this is where this kind of complex-looking code comes into play.

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swiJh6QMwkP6sfDJYgETwVx7ARJpmR2TbPLS6QPr5SgGmwL6tgFTetX1cHHYFctfUG6.png)

The spaces variable holds several spaces (CHR$ 32 for ASCII buffs), and that number is 20 minus the length of the Splinterlands account name.

It does look a little cryptic but can be figured out if you stare long enough at it while drinking lots of coffee and occasionally pounding your head against the nearest wall.

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swiWmec8HFvxh1WECcGdcSK4QorjMwmn7cwRwHrriNvGyoMQY5LggBetbSaAEXvSqfY.png)

The final line is something I am still getting used to with Python. Adding 3 x {} separated by a comma, with the next 3 elements dictates what will be within them.

Note the middle one contains the variable 'spaces' which is simply padding so then when the script is run, it looks nice and ordered.

I do intend to create a GitHub repository for these scripts. As I still haven’t done this, please feel free to copy and paste the entire script if you find it useful.

Replace my accounts with yours unless you simply want to spy on my DEC totals. The script could easily be modified to display much more than DEC, and that one line pipes a lot of data into the 'url' variable.


![RedLine.png](https://files.peakd.com/file/peakd-hive/slobberchops/246bHiHbRfQjcEkvuD5ZVRvw29C4Aas1iYDEwtReeDiSQvkVR31FKYpYdHUK9egHprYqW.png)


**SplinterlandsDECBalances.py**

	import json, requests

	splinterlands_accounts = ["account1", "account2", "account3"]

	print("----------------------------------")
	print("Account               DEC Total")
	print("----------------------------------")

	for account in splinterlands_accounts:

	    url = "https://api2.splinterlands.com/players/balances?username=" + account
	    spldata = json.loads(requests.get(url).text)

    	for data in spldata:
        	if data["token"] == "DEC":
	            spaces = " " * (20-len(data['player']))
        	    print("{} {} {}".format(data['player'], spaces, data['balance']))


![RedLine.png](https://files.peakd.com/file/peakd-hive/slobberchops/BqIuXs6C-RedLine.png)

<H6>
 - Earn currency while you play brewing virtual beer with [CryptoBrewMaster](https://www.cryptobrewmaster.io/game/invite?ref=9846a8af82df4dd0bc23192a135df232&code=AlphaBonus)
 - Earn currency while you play and become a global Rock Star with [Rising Star](https://www.risingstargame.com?referrer=slobberchops)
</H6>

<center>
![CurieCurator.jpg](https://files.peakd.com/file/peakd-hive/slobberchops/f5zec6UG-CurieCurator.jpg)
</center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 592 others
👎  , , , , , ,
properties (23)
authorslobberchops
permlinkpython-libraries-simple-display-your-splinterlands-dec
categoryhive-163521
json_metadata{"app":"peakd/2022.10.1","format":"markdown","tags":["python","stemgeeks","leofinance","proofofbrain","palnet","creativecoin","neoxian","vyb","ctp"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/slobberchops/23swigvWKHx2p6RcKVsHRYkxBKBi9R4swCbxPL8cv46RzBUGaPAzVWYgPUfC39YUrEZqa.png","https://files.peakd.com/file/peakd-hive/slobberchops/23zkbfDfmRmdyMkoXYTQncNa59ssfY1NL8ZJ1nNncUNN4bPrv7uhPZ7QvqbjDFWcnNpLQ.png","https://files.peakd.com/file/peakd-hive/slobberchops/23swiP3uYksZShMMmceAc9Qaz3grvrcxh3KjuvghF6koP9WuyuXzfBJLUckDNYuNtJBiG.png","https://files.peakd.com/file/peakd-hive/slobberchops/23swibVytFW2kgSbTGBhzvvahAc286PpkE1of1tK1WvXnagoni3j98BRCSmkVZCkET7gv.png","https://files.peakd.com/file/peakd-hive/slobberchops/23t77B9E8yEVdZ2hPL7QdNzxNaKvx6hpKMFK7VSvtsS3AK8YBrs9BbCW2HQp9wwybLqJ4.png","https://files.peakd.com/file/peakd-hive/slobberchops/23swiJgS1GyqHSYuum2qfmoiiS5XJmTgTJAxUSbdskKcoEtBJQELsiazVictseKv65biM.png","https://files.peakd.com/file/peakd-hive/slobberchops/23swiNxYVGQfjnH1JGgvDqxt9AJWc7bccc58MmZJU3EvyHqwCy63gP3iUDNVoHuUehChg.png","https://files.peakd.com/file/peakd-hive/slobberchops/23swiJh6QMwkP6sfDJYgETwVx7ARJpmR2TbPLS6QPr5SgGmwL6tgFTetX1cHHYFctfUG6.png","https://files.peakd.com/file/peakd-hive/slobberchops/23swiWmec8HFvxh1WECcGdcSK4QorjMwmn7cwRwHrriNvGyoMQY5LggBetbSaAEXvSqfY.png","https://files.peakd.com/file/peakd-hive/slobberchops/246bHiHbRfQjcEkvuD5ZVRvw29C4Aas1iYDEwtReeDiSQvkVR31FKYpYdHUK9egHprYqW.png","https://files.peakd.com/file/peakd-hive/slobberchops/BqIuXs6C-RedLine.png","https://files.peakd.com/file/peakd-hive/slobberchops/f5zec6UG-CurieCurator.jpg"]}
created2022-10-17 09:01:12
last_update2022-10-17 09:01:12
depth0
children34
last_payout2022-10-24 09:01:12
cashout_time1969-12-31 23:59:59
total_payout_value52.018 HBD
curator_payout_value51.874 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,875
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,537,437
net_rshares172,174,812,286,314
author_curate_reward""
vote details (663)
@akumagai ·
$0.05
Coding!

And lots of hair pulling.

Equals bald coders lol.
👍  , , , ,
properties (23)
authorakumagai
permlinkrjx4zw
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2022-10-17 22:26:21
last_update2022-10-17 22:26:21
depth1
children0
last_payout2022-10-24 22:26:21
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.024 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length59
author_reputation82,467,923,972,644
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,555,350
net_rshares82,174,745,124
author_curate_reward""
vote details (5)
@bashadow ·
$0.07
Thank you, This was pretty interesting to me. I need to break out my Rasp-Pi and give it a try one day. I am still wary about trying things on my everyday computer.
👍  , , , ,
properties (23)
authorbashadow
permlinkre-slobberchops-rjwpv3
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 16:59:30
last_update2022-10-17 16:59:30
depth1
children2
last_payout2022-10-24 16:59:30
cashout_time1969-12-31 23:59:59
total_payout_value0.037 HBD
curator_payout_value0.036 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length164
author_reputation100,388,692,638,882
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,547,030
net_rshares123,500,054,832
author_curate_reward""
vote details (5)
@slobberchops ·
$0.07
> I am still wary about trying things on my everyday computer.

It will be fine, clear text script!
👍  , , , , ,
properties (23)
authorslobberchops
permlinkre-bashadow-rjwvx4
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 19:10:15
last_update2022-10-17 19:10:15
depth2
children1
last_payout2022-10-24 19:10:15
cashout_time1969-12-31 23:59:59
total_payout_value0.036 HBD
curator_payout_value0.034 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length99
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,550,575
net_rshares118,790,096,606
author_curate_reward""
vote details (6)
@bashadow ·
$0.03
properties (23)
authorbashadow
permlinkre-slobberchops-rjww91
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 19:17:27
last_update2022-10-17 19:17:27
depth3
children0
last_payout2022-10-24 19:17:27
cashout_time1969-12-31 23:59:59
total_payout_value0.014 HBD
curator_payout_value0.014 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7
author_reputation100,388,692,638,882
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,550,793
net_rshares49,804,719,683
author_curate_reward""
vote details (5)
@beerlover ·
<div class='pull-right'>https://files.peakd.com/file/peakd-hive/beerlover/yiuU6bdf-beerlover20gives20BEER.gif<p><sup><a href='https://hive-engine.com/?p=market&t=BEER'>View or trade </a> <code>BEER</code>.</sup></p></div><center><br> <p>Hey @slobberchops, here is a little bit of <code>BEER</code> from @joanstewart for you. Enjoy it!</p> <p>Do you want to <a href='https://friends.beersaturday.com/'>win <b>SOME BEER</b> together with your friends </a> and draw the <code>BEERKING</code>.</p> </center><div></div>
properties (22)
authorbeerlover
permlinkre-slobberchops-python-libraries-simple-display-your-splinterlands-dec-20221017t131135758z
categoryhive-163521
json_metadata{"app":"beerlover/3.0","language":"rust","developer":"wehmoen"}
created2022-10-17 13:11:36
last_update2022-10-17 13:11:36
depth1
children0
last_payout2022-10-24 13:11:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length515
author_reputation25,761,508,188,824
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,541,962
net_rshares0
@dlmmqb ·
$0.05
Thanks for writing this blog, the code run smoothly. Also, it was short and educational.
👍  , , , ,
properties (23)
authordlmmqb
permlinkre-slobberchops-rjw4pc
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 09:22:24
last_update2022-10-17 09:22:24
depth1
children2
last_payout2022-10-24 09:22:24
cashout_time1969-12-31 23:59:59
total_payout_value0.026 HBD
curator_payout_value0.025 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length88
author_reputation294,237,939,236,421
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,537,754
net_rshares88,649,838,655
author_curate_reward""
vote details (5)
@slobberchops ·
Short should make it more understandable. These long winding scripts have my head exploding.
👍  , , , , , ,
properties (23)
authorslobberchops
permlinkre-dlmmqb-rjwat3
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 11:34:15
last_update2022-10-17 11:34:15
depth2
children1
last_payout2022-10-24 11:34:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length92
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,540,143
net_rshares17,819,987,914
author_curate_reward""
vote details (7)
@dlmmqb · (edited)
This is why I mentioned it. I wanted to give it a 1up but because of leofinance and ctp tag I got confused to be honest so I skipped. I take tags seriously when it comes to 1up and it's not always crystal clear so arguments mostly end up hurting feelings of author then doing any good so i just skip.
👍  , , ,
properties (23)
authordlmmqb
permlinkre-slobberchops-rjwcao
categoryhive-163521
json_metadata{"tags":"hive-163521"}
created2022-10-17 12:06:24
last_update2022-10-17 12:07:18
depth3
children0
last_payout2022-10-24 12:06:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length300
author_reputation294,237,939,236,421
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,540,708
net_rshares1,578,467,012
author_curate_reward""
vote details (4)
@ecency ·
$0.02
Your content has been **voted** as a part of [Encouragement program](https://ecency.com/ecency/@good-karma/encouragement-program-continues-82eafcd10a299). Keep up the good work! <br><br>Use Ecency daily to boost your growth on platform! <br><br><b>Support Ecency</b><br>[Vote for new Proposal](https://hivesigner.com/sign/update-proposal-votes?proposal_ids=%5B197%5D&approve=true)<br>[Delegate HP and earn more](https://ecency.com/hive-125125/@ecency/daily-100-curation-rewards)
👍  
properties (23)
authorecency
permlinkre-20221017t9725997z
categoryhive-163521
json_metadata{"tags":["ecency"],"app":"ecency/3.0.20-welcome","format":"markdown+html"}
created2022-10-17 09:07:27
last_update2022-10-17 09:07:27
depth1
children0
last_payout2022-10-24 09:07:27
cashout_time1969-12-31 23:59:59
total_payout_value0.012 HBD
curator_payout_value0.012 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length478
author_reputation613,589,286,978,643
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,537,532
net_rshares41,707,297,049
author_curate_reward""
vote details (1)
@jlinaresp ·
$0.05
"*In an attempt to write something ‘useful’ without stealing it from the internet I set about trying out the Splinterlands API for the first time.*"

Haaaaa haaaa haaaaa :))

It's a pleasure to read you, my friend!.... Thank you!!!!... 
👍  , , , ,
properties (23)
authorjlinaresp
permlinkre-slobberchops-rjx1fv
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 21:09:30
last_update2022-10-17 21:09:30
depth1
children0
last_payout2022-10-24 21:09:30
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.023 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length236
author_reputation941,114,444,110,717
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,553,755
net_rshares82,208,382,076
author_curate_reward""
vote details (5)
@joanstewart ·
$0.05
Dipping you toes in to learn something different, frustrating and rewarding, thanks for insight on what you been doing. 

!BEER
👍  , , , ,
properties (23)
authorjoanstewart
permlinkre-slobberchops-20221017t151119878z
categoryhive-163521
json_metadata{"tags":["python","stemgeeks","leofinance","proofofbrain","palnet","creativecoin","neoxian","vyb","ctp"],"app":"ecency/3.0.28-vision","format":"markdown+html"}
created2022-10-17 13:11:18
last_update2022-10-17 13:11:18
depth1
children3
last_payout2022-10-24 13:11:18
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.024 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length127
author_reputation393,450,236,936,169
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,541,957
net_rshares85,246,105,713
author_curate_reward""
vote details (5)
@slobberchops ·
I used to code as part of my work, but being out of work has not helped much. Python was new to me, but I have adjusted to it well.
👍  , , , ,
properties (23)
authorslobberchops
permlinkre-joanstewart-rjwl5l
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 15:17:45
last_update2022-10-17 15:17:45
depth2
children2
last_payout2022-10-24 15:17:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length131
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,544,494
net_rshares1,572,306,509
author_curate_reward""
vote details (5)
@joanstewart ·
$0.05
Fiddled a couple of years with code, not Python though. Would need time and quiet to sit fathoming out which I have not had recently... 😇 Enjoy something different, learning new is never lost always put to good use.
👍  
properties (23)
authorjoanstewart
permlinkre-slobberchops-rjxtij
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-18 07:15:57
last_update2022-10-18 07:15:57
depth3
children1
last_payout2022-10-25 07:15:57
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.023 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length215
author_reputation393,450,236,936,169
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,564,089
net_rshares80,706,922,314
author_curate_reward""
vote details (1)
@katirayo ·
Great content again my best author you are the best author i ever came across but that is by the way, you really explained this well the python should be a broad topic, I mean maybe you should do a podcast about it just a suggestion thanks for sharing.
👍  , , , ,
👎  ,
properties (23)
authorkatirayo
permlinkre-slobberchops-rjwspw
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 18:01:33
last_update2022-10-17 18:01:33
depth1
children0
last_payout2022-10-24 18:01:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length252
author_reputation19,476,347,900,657
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,548,942
net_rshares-131,058,608,911
author_curate_reward""
vote details (7)
@libertycrypto27 · (edited)
$0.13
It has been many years since I enjoyed playing with C++, Java and Postgree SQL. Then life and work and limited time took me away from programming.
I never had time to study Phyton and who knows Hive might be the right motivation to start studying Phyton.

>There are scripts on GitHub that do a lot more than what I show you here, but lifting them won't teach you Python.

Great advice and I completely agree.
Writing the code is the only way to learn it.
@tipu curate
👍  , , , ,
properties (23)
authorlibertycrypto27
permlinkre-slobberchops-20221017t11349944z
categoryhive-163521
json_metadata{"tags":["python","stemgeeks","leofinance","proofofbrain","palnet","creativecoin","neoxian","vyb","ctp"],"app":"ecency/3.0.28-vision","format":"markdown+html"}
created2022-10-17 09:34:09
last_update2022-10-17 09:34:36
depth1
children2
last_payout2022-10-24 09:34:09
cashout_time1969-12-31 23:59:59
total_payout_value0.065 HBD
curator_payout_value0.064 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length468
author_reputation1,954,530,611,158,369
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,537,910
net_rshares219,306,647,850
author_curate_reward""
vote details (5)
@slobberchops ·
I struggle with Python, probably because I am don't use it daily. Even my own code.. I forget how it works.., but understanding it is the only way you will ever gain any knowledge. Lifting code is fine.., but it doesn't get you very far.
👍  , , , , , , ,
properties (23)
authorslobberchops
permlinkre-libertycrypto27-rjwavn
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 11:35:48
last_update2022-10-17 11:35:48
depth2
children0
last_payout2022-10-24 11:35:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length237
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,540,166
net_rshares17,374,325,014
author_curate_reward""
vote details (8)
@tipu ·
<a href="https://tipu.online/hive_curator?libertycrypto27" target="_blank">Upvoted  &#128076;</a> (Mana: 29/39) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-slobberchops-20221017t11349944z-20221017t093414z
categoryhive-163521
json_metadata"{"app": "beem/0.24.26"}"
created2022-10-17 09:34:15
last_update2022-10-17 09:34:15
depth2
children0
last_payout2022-10-24 09:34:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length223
author_reputation55,902,105,514,997
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,537,911
net_rshares0
@onw ·
$0.12
Well, you piqued my interest!

This got me to install Python 3 and, using PIP to add the requests repository.

After all that I thought I would contribute by adding a total...

Altered the code as follows:

import json, requests

splinterlands_accounts = ["account1", "account2", "account3"]

print("----------------------------------")
print("Account               DEC Total")
print("----------------------------------")

totalDEC = float("0")

for account in splinterlands_accounts:

    url = "https://api2.splinterlands.com/players/balances?username=" + account
    spldata = json.loads(requests.get(url).text)

    for data in spldata:
        if data["token"] == "DEC":
            spaces = " " * (20-len(data['player']))
            print("{} {} {}".format(data['player'], spaces, data['balance']))
            totalDEC = totalDEC + float(data['balance'])

print("----------------------------------")
spaces = " " * (18-len(str(totalDEC)))
print("{} {} {}".format("Total DEC", spaces, str(totalDEC)))
print("----------------------------------")
👍  ,
properties (23)
authoronw
permlinkre-slobberchops-rjyipa
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-18 16:20:03
last_update2022-10-18 16:20:03
depth1
children1
last_payout2022-10-25 16:20:03
cashout_time1969-12-31 23:59:59
total_payout_value0.061 HBD
curator_payout_value0.061 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,051
author_reputation15,954,360,789,244
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,575,119
net_rshares204,008,716,608
author_curate_reward""
vote details (2)
@slobberchops ·
Great, have a go at doing something else, and install the BEEM library.., then you can truly manipulate HIVE stuff.
properties (22)
authorslobberchops
permlinkre-onw-rjymlm
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-18 17:44:12
last_update2022-10-18 17:44:12
depth2
children0
last_payout2022-10-25 17:44:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length115
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,577,240
net_rshares0
@poshtoken · (edited)
$0.04
https://twitter.com/904656441772007424/status/1581989155831439360
https://twitter.com/1294348333847400455/status/1582036125392044034
https://twitter.com/189169040/status/1582117710137548800
<sub> The rewards earned on this comment will go directly to the people( @joydukeson, @fabian98, @jlinaresp ) sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.</sub>
👍  
properties (23)
authorposhtoken
permlinkre-slobberchops-python-libraries-simple-display-your-splinterlands15957
categoryhive-163521
json_metadata"{"app":"Poshtoken 0.0.1","payoutToUser":["joydukeson","fabian98","jlinaresp"]}"
created2022-10-17 12:45:51
last_update2022-10-17 21:16:48
depth1
children0
last_payout2022-10-24 12:45:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.036 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length415
author_reputation5,148,213,386,933,320
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries
0.
accountreward.app
weight10,000
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id117,541,425
net_rshares119,190,751,716
author_curate_reward""
vote details (1)
@rikoy ·
i started learning python, i want to do more with python.
👍  , , ,
properties (23)
authorrikoy
permlinkrjwpzd
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2022-10-17 17:02:06
last_update2022-10-17 17:02:06
depth1
children0
last_payout2022-10-24 17:02:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length57
author_reputation2,225,002,197,666
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,547,113
net_rshares1,566,181,333
author_curate_reward""
vote details (4)
@sapphirecrypto ·
$0.05
At the end of the day, you keep producing the best content you can, engage and respond. The rest is outside of your control. Probably not an idea that is appealing to most... people want guarantees, along with instant gratification. Not gonna happen...
👍  , , , ,
properties (23)
authorsapphirecrypto
permlinkrjwx1s
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2022-10-17 19:34:42
last_update2022-10-17 19:34:42
depth1
children0
last_payout2022-10-24 19:34:42
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.023 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length252
author_reputation179,089,130,469,682
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,551,204
net_rshares82,240,083,897
author_curate_reward""
vote details (5)
@steevc ·
$0.25
I recommend looking at Python 'fstrings'. They make for simpler formatting. Here's an example I came up with that pads out names and numbers. Easier to read I think:

```
x=[{'name':'rod','amt':3},{'name':'jane','amt':555},{'name':'freddy','amt':111}]
for i in x:
    print(f"{i['name']:20} {i['amt']:6}")
```

Output:
```
rod                       3
jane                    555
freddy                  111
```
👍  , , , , ,
👎  ,
properties (23)
authorsteevc
permlinkre-slobberchops-rjw73a
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 10:13:57
last_update2022-10-17 10:13:57
depth1
children8
last_payout2022-10-24 10:13:57
cashout_time1969-12-31 23:59:59
total_payout_value0.124 HBD
curator_payout_value0.123 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length410
author_reputation1,368,593,959,675,459
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,538,575
net_rshares413,038,896,830
author_curate_reward""
vote details (8)
@slobberchops ·
$0.10
More efficient for sure (1 line less of coding), but getting my head around it was tough. It does it for you! Here's the adjusted section of code:

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23swiWkazkiUhSm8EU36gs1NvKhecVH9NZaQNYDucCxJ5D3SH8nSawiQzJndLhqT6KQf2.png)

![image.png](https://files.peakd.com/file/peakd-hive/slobberchops/23t793AB6jBwa4LmUZ1tTvjAdVHe72mLUwmbta1wyWoCaQAAjDoo5ScExGZCQV45KHmmi.png)

Thanks for the lesson, I was never a master.., but can get by!

👍  , , , ,
👎  ,
properties (23)
authorslobberchops
permlinkre-steevc-rjwaqf
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 11:32:39
last_update2022-10-17 11:32:39
depth2
children7
last_payout2022-10-24 11:32:39
cashout_time1969-12-31 23:59:59
total_payout_value0.050 HBD
curator_payout_value0.049 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length496
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,540,117
net_rshares165,382,109,540
author_curate_reward""
vote details (7)
@steevc ·
$0.11
It's pretty powerful and generally quite readable. You can also align the numbers to the right. It's something I use all the time, but I don't know all the tricks.
👍  , , , , ,
👎  ,
properties (23)
authorsteevc
permlinkre-slobberchops-rjwbi5
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 11:49:15
last_update2022-10-17 11:49:15
depth3
children6
last_payout2022-10-24 11:49:15
cashout_time1969-12-31 23:59:59
total_payout_value0.056 HBD
curator_payout_value0.056 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length163
author_reputation1,368,593,959,675,459
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,540,384
net_rshares187,135,452,276
author_curate_reward""
vote details (8)
@wrestlingdesires ·
$0.05
>You need to write them from nothing and without looking if you want it all to sink in.

That sounds like a good plan - but then, when would one find time to write???

This post has been manually curated by the VYB curation project
👍  , , , ,
properties (23)
authorwrestlingdesires
permlinkre-slobberchops-20221017t54651712z
categoryhive-163521
json_metadata{"tags":["python","stemgeeks","leofinance","proofofbrain","palnet","creativecoin","neoxian","vyb","ctp"],"app":"ecency/3.0.28-vision","format":"markdown+html"}
created2022-10-17 13:46:51
last_update2022-10-17 13:46:51
depth1
children1
last_payout2022-10-24 13:46:51
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.024 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length231
author_reputation202,688,216,355,345
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,542,593
net_rshares85,221,012,876
author_curate_reward""
vote details (5)
@slobberchops ·
> That sounds like a good plan - but then, when would one find time to write???

There's little point in doing anything unless you have a goal. Time.., that depends on your lifestyle and what's more important.
👍  , , , , ,
properties (23)
authorslobberchops
permlinkre-wrestlingdesires-rjwl75
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2022.10.1"}
created2022-10-17 15:18:42
last_update2022-10-17 15:18:42
depth2
children0
last_payout2022-10-24 15:18:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length209
author_reputation2,426,841,754,216,432
root_title"Python Libraries: Simple... Display your Splinterlands DEC "
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,544,520
net_rshares1,568,216,542
author_curate_reward""
vote details (6)