Skip to Main Content
Python程序设计:人工智能案例实践
book

Python程序设计:人工智能案例实践

by 保罗 戴特尔, 哈维 戴特尔
August 2021
Intermediate to advanced content levelIntermediate to advanced
450 pages
13h 28m
Chinese
Pearson
Content preview from Python程序设计:人工智能案例实践

16.8.5 创建一个Python PubNub订阅服务器

PubNub提供pubnub Python模块,用于方便地执行发布/订阅操作,还提供了7个样本流供用户使用4个实时流和3个模拟流进行实验[1]

▪ Twitter Stream(Twitter流)—从Twitter实时流每秒提供多达50条推文,并且不需要用户的Twitter凭据。

▪ Hacker News Articles(黑客新闻文章)—该网站的最新文章。

▪ State Capital Weather(州首府天气)—提供美国州首府的天气数据。

▪ Wikipedia Changes(Wikipedia更改)—Wikipedia编辑流。

▪ Game State Sync(游戏状态同步)—模拟来自多人游戏的数据。

▪ Sensor Network(传感器网络)—来自辐射、湿度、温度和环境光传感器的模拟数据。

▪ Market Orders(市场订单)—模拟五家公司的股票订单。

这里,将使用pubnub模块订阅其模拟的Market Orders流,然后将不断变化的股票价格可视化为Seaborn原型,如下所示。

当然,也可以将消息发布到流。有关详细信息,请参阅https://www.pubnub.com/docs/python/pubnub-python-sdk。

要准备在Python中使用PubNub,请执行以下命令安装最新版本的pubnub模块

    pip install "pubnub>=4.1.2"

使用脚本 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

数据科学中的实用统计学(第2版)

数据科学中的实用统计学(第2版)

Peter Bruce, Andrew Bruce, Peter Gedeck
Python算法交易实战

Python算法交易实战

Posts & Telecom Press, Sebastien Donadio
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787111678458