I'm trying to check a simple flag to be true or false, but my IF statement fails and it doesn't give me the correct result, Hope someone can help!
I'm using (in python3.6) this url
http://ift.tt/2BCjUvT
for a get request and the data it should return looks like this (from URL in browser):
{"success":true,"message":"","result":{"Bid":18362.00000000,"Ask":18399.00000000,"Last":18362.00000000}}
Here is my program:
import sys
import time
import requests
import json
import os
BTCtick = 'http://ift.tt/2BCjUvT'
reqBTC = requests.get('http://ift.tt/1DFS2ly? market=usdt-btc').text
BTCdata = json.loads(reqBTC)
testResult = BTCdata['success']
print("=============================")
print("success content: ", BTCdata['success'])
if (testResult == 'True'):
print("IF: success flag is TRUE")
else:
print("IF: success flag is FALSE")
print("=============================")
print("result content: ", BTCdata['result'])
print("Bid: ", BTCdata['result'] ['Bid'], sep='')
print("Ask: ", BTCdata['result'] ['Ask'], sep='')
print("Last: ", BTCdata['result'] ['Last'], sep='')
print("=============================")
exit()
Output in the console looks like this:
=============================
success content: True
IF: success flag is FALSE
=============================
result content: {'Bid': 18420.0, 'Ask': 18439.99999999, 'Last': 18439.99999999}
Bid: 18420.0
Ask: 18439.99999999
Last: 18439.99999999
=============================
Any idea what I'm missing here? I'm sure it is simple Please please help me, I'm somewhat new to python and kind find out what's wrong, I have been reading a lot the last two days, but could not find the issue!
Aucun commentaire:
Enregistrer un commentaire