0%

.text与.content的区别

requests的官方文档有这么一段:

We can read the content of the server’s response. Consider the GitHub timeline again: >>> import requests >>> r = requests.get(‘https://api.github.com/events') >>> r.text u’[{“repository”:{“open_issues”:0,”url”:”https://github.com/... Requests will automatically decode content from the server. Most unicode charsets are seamlessly decoded. When you make a request, Requests makes educated guesses about the encoding of the response based on the HTTP headers. The text encoding guessed by Requests is used when you access r.text. You can find out what encoding Requests is using, and change it, using the r.encoding property: >>> r.encoding ‘utf-8’ >>> r.encoding = ‘ISO-8859-1’ If you change the encoding, Requests will use the new value of r.encoding whenever you call r.text. You might want to do this in any situation where you can apply special logic to work out what the encoding of the content will be. For example, HTTP and XML have the ability to specify their encoding in their body. In situations like this, you should use r.content to find the encoding, and then set r.encoding. This will let you use r.text with the correct encoding. Requests will also use custom encodings in the event that you need them. If you have created your own encoding and registered it with the codecs module, you can simply use the codec name as the value of r.encoding and Requests will handle the decoding for you.

阅读全文 »

Supervisor 是基于 Python 的进程管理工具,只能运行在 Unix-Like 的系统上,Supervisor可以很方便的用来启动、重启、关闭进程。除了对单个进程的控制,还可以同时启动、关闭多个进程。

组成

Supervisor 有两个主要的组成部分:

  • supervisord
    • 运行 Supervisor 时会启动一个supervisord进程,它负责启动所管理的进程,并将所管理的进程作为自己的子进程来启动,而且可以在所管理的进程出现崩溃时自动重启。
  • supervisorctl
    • 是命令行管理工具,可以用来执行 stop、start、restart 等命令,来对这些子进程进行管理。
阅读全文 »

Discourse 是 Stack Overflow 的联合创始人 Jeff Atwood 推出的一个新的开源论坛项目,其目的是为了改变十年未变的论坛软件。它摒弃了传统论坛的话题讨论形式、拥有自学习系统、全Web应用同时适用于桌面和移动终端。

阅读全文 »

ansible 是一个模型驱动的配置管理器,支持多节点发布、远程任务执行。默认使用 SSH 进行远程连接。无需在被管理节点上安装附加软件,可使用各种编程语言进行扩展。

ansible 基于Python语言实现,由Paramiko和PyYAML两个关键模块构建,特点有:

  • 部署简单,只要主控端部署ansible环境,被控端无需任何操作
  • 默认使用SSH协议对设备进行管理
  • 主从集中化管理
  • 配置简单,功能强大扩展性强
  • 支持API及自定义模块,可通过Python轻松扩展
  • 通过playbook定制强大配置、状态管理
阅读全文 »

DokuWiki是一个开源wiki引擎程序,运行于PHP环境下。Doku Wiki 程序小巧而功能强大、灵活,适合中小团队和个人网站知识库的管理。 DokuWiki可以与多种CMS程序进行整合,例如WordPress、XOOPS、PostNuke等。由于这个原因,很多Blog作者对DokuWiki比较感兴趣。

阅读全文 »