0
点赞
收藏
分享

微信扫一扫

让mac电脑播报当前行情价格


下边是设置和实现方法


一、先设置使mac的语音听写可以使用。


1.打开系统设置


 2.打开听说键盘->语音听说设置




3.打开辅助工具












python脚本如下


#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys,os

import httplib

import time
import json

import urllib2

httpClient = None

def getTicker():
try:
httpClient = httplib.HTTPConnection('data.btcchina.com', 80, timeout=30)
httpClient.request('GET', '/data/ticker?market=ltccny')
response = httpClient.getresponse()
data = response.read()
return data
except Exception, e:
print e
finally:
if httpClient:
httpClient.close()
return 0

def main():
# depthtmp = getDepth() #market depth
tickertmp = getTicker()
tmp = json.loads(tickertmp)
out = '最新价' + str(tmp['ticker']['last']) + ',买' + str(tmp['ticker']['buy']) + ',卖' + str(tmp['ticker']['sell'])
print out
if __name__ == '__main__':
main()到这里整个自动报价设置就完成了。这时你要是想听现在最新价,只要对着电脑说"旺财,当前价格"就可以,电脑会用语音告诉你当前价,买一价,卖一价。

举报

相关推荐

0 条评论