我想让值根据指定范围内的值输出返回响应。
import requests
import json
import time
url = 'https://api.gdax.com/products/BTC-USD/trades'
res = requests.get(url)
json_res = json.loads(res.text)
print('val ', json_res[0]['price'])
buy = range(32000, 36000)
sell = range(39000, 50000)
if json_res in buy:
print('Low')
elif json_res in sell:
print('Too High')
这是我正在寻找的输出示例
val 38000.00002545
Too High
import requests
import json
import time
url = 'https://api.gdax.com/products/BTC-USD/trades'
res = requests.get(url)
json_res = json.loads(res.text)
print('val ', json_res[0]['price'])
buy = range(32000, 36000)
sell = range(39000, 50000)
if float(json_res[0]['price']) in buy:
print('Low')
elif float(json_res[0]['price']) in sell:
print('Too High')
else:
if float(json_res[0]['price']) <32000:
print('Lower Than low')
elif float(json_res[0]['price']) >50000:
print('Higher Than high')
else:
print('In Between')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句