From 19ffbd6eded10c8630d0bbdedc77ac46fb174177 Mon Sep 17 00:00:00 2001 From: DarthKeizer Date: Thu, 11 May 2017 10:11:38 +0200 Subject: [PATCH] Update twittertweeter-ads.py Adjusted data percentage to 2 decimals with %.2f and ofcourse converting to float --- twittertweeter-ads.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twittertweeter-ads.py b/twittertweeter-ads.py index 7dcad09..ce62cba 100644 --- a/twittertweeter-ads.py +++ b/twittertweeter-ads.py @@ -11,10 +11,10 @@ data = urlopen('path/to/admin/api.php').read() #bytes body = data.decode('utf-8') data = json.loads(body) -# Create tweet -template_tweet = "\nAds Blocked: %s\nAds Percentage Today: %s\nDNS Queries Today: %s\nDomains Being Blocked: %s" +# Create tweet, adjust %.2f for amount of decimals you want +template_tweet = "\nAds Blocked: %s\nAds Percentage Today: %.2f\nDNS Queries Today: %s\nDomains Being Blocked: %s" data = template_tweet % (data['ads_blocked_today'], - data['ads_percentage_today'], + float (data['ads_percentage_today']), data['dns_queries_today'], data['domains_being_blocked'] )