Skip to Content
Python数据处理
book

Python数据处理

by Jacqueline Kazil, Katharine Jarmul
July 2017
Intermediate to advanced
398 pages
11h 54m
Chinese
Posts & Telecom Press
Content preview from Python数据处理
326
14
config = get_config('DEV')
client = get_client(config)
message_room(client, 'My Favorite Room', "I'M A ROBOT!")
使用
HypChat
库同聊天室客户端交谈。这个库使用
HipChat token
初始化一个新的客户
端,我们将
token
保存在配置文件中。
这行代码使用
get_room
方法,选择与字符串名称匹配的房间。
这行代码使用
message
方法发送一条信息到一个房间或者一个用户,传递给函数一个简
单的字符串,里面包含想说的内容。
总是在基于
API
库的周围使用
try...except
代码块,以应对连接错误或者
API
改变带
来的异常。这段代码打印了错误,但是你可能更想打印日志,以充分地自动化脚本。
这里使用的函数
get_config
是从不同的脚本中导入的。通过引入这些辅助函数,并且将
它们放置到独立的模块中复用,我们遵循了模块化的代码设计。
如果想要登录到聊天室,你可以使用
HipLogging
https://github.com/invernizzi/hiplogging
探索这些选项。取决于需求和团队的工作方式,你可以根据自己的喜好设置聊天室的登录
功能;但是好消息是,你总是可以在他们可能看见的地方留下笔记!
如果你更喜欢
Google Chat
,有很多非常棒的示例展示了如何使用
SleekXMPP
http://
sleekxmpp.com/getting_started/sendlogout.html ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

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

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

Peter Bruce, Andrew Bruce, Peter Gedeck
Java持续交付

Java持续交付

Daniel Bryant, Abraham Marín-Pérez
解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787115459190