毛熊爸
魔神至尊
苹果神教
import os import json import urllib2 huobi = json.load(urllib2.urlopen("http://www.btc123.com/e/interfaces/tickers.php?type=huobiTicker")) hbprice = huobi['ticker']['last'] btce = json.load(urllib2.urlopen("http://www.btc123.com/e/interfaces/tickers.php?type=btceBTCUSDticker")) btceprice = btce['ticker']['last'] #usdrate = json.load(urllib2.urlopen("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22USDCNY%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=")) #rate = usdrate['query']['results']['rate']['Rate'] rate = 6.04 x = float(hbprice) y = float(btceprice) z = float(rate) w = y*z if (w<x): small,big=w,x else: small,big=x,w result = (big-small)/big*100 if small==x: low = "The Lower is HUOBI" else: low = "The Lower is BTCE" print "HUOBI PRICE",x print "BTCE PRICE",w print low print result
import os import json import urllib2 huobi = json.load(urllib2.urlopen("http://www.btc123.com/e/interfaces/tickers.php?type=huobiTicker")) hbprice = huobi['ticker']['last'] btce = json.load(urllib2.urlopen("http://www.btc123.com/e/interfaces/tickers.php?type=btceBTCUSDticker")) btceprice = btce['ticker']['last'] #usdrate = json.load(urllib2.urlopen("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22USDCNY%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=")) #rate = usdrate['query']['results']['rate']['Rate'] rate = 6.04 x = float(hbprice) y = float(btceprice) z = float(rate) w = y*z if (w<x): small,big=w,x else: small,big=x,w result = (big-small)/big*100 if small==x: low = "The Lower is HUOBI" else: low = "The Lower is BTCE" def notify(title, subtitle, message): t = '-title {!r}'.format(title) s = '-subtitle {!r}'.format(subtitle) m = '-message {!r}'.format(message) os.system('terminal-notifier {}'.format(' '.join([m, t, s]))) trigger = 2.5 if result<trigger: print result else: notify( title = low , subtitle = 'Diffrence Percent is', message = result )
查看详细资料
TOP
魔王撒旦
天外飞仙
小黑屋
伦家不要啦
卍解
版主
大能猫
原帖由 @meizizi 于 2014-1-15 13:34 发表 posted by wap, platform: Android 原来那个自动换桌面也是LZ做的吗?
小侠
魔头
嫩腾云
混世魔头
原帖由 alexacc 于 2014-1-16 14:37 发表 if small==x: 我想问python支持浮点数相等比较?精度怎么控制