==cStringIO 模块==

``cStringIO`` 是一个可选的模块, 是 ``StringIO`` 的更快速实现. 它的工作方式和 ``StringIO`` 基本相同,
但是它不可以被继承. [Example 2-11 #eg-2-11] 展示了 ``cStringIO`` 的用法, 另参考前一节. ====Example 2-11. 使用 cStringIO 模块====[eg-2-11] ```
File: cstringio-example-1.py import cStringIO MESSAGE = "That man is depriving a village somewhere of a computer scientist." file = cStringIO.StringIO(MESSAGE) print file.read() *B*That man is depriving a village somewhere of a computer scientist.*b*
``` 为了让你的代码尽可能快, 但同时保证兼容低版本的 Python ,你可以使用一个小技巧在 ``cStringIO``
不可用时启用 ``StringIO`` 模块, 如 [Example 2-12 #eg-2-12] 所示. ====Example 2-12. 后退至 StringIO====[eg-2-12] ```
File: cstringio-example-2.py try:
import cStringIO
StringIO = cStringIO
except ImportError:
import StringIO print StringIO *B*<module 'StringIO' (built-in)>*b*
```

最新文章

  1. iOS -- 处理推送消息
  2. Can’t Activate Reporting Services Service in SharePoint
  3. Log4net使用(一)
  4. python中2进制、10进制、16进制等之间的转换
  5. 【转】Linux网络相关查询脚本
  6. Flex基础相关
  7. java 、Android 提交参数转码问题
  8. windows下qtcreator添加ICE库文件
  9. HDOJ-1007 Quoit Design(最近点对问题)
  10. ECshop lib_base.php on line 1241 错误解决方法
  11. CSS设计指南之理解盒子模型
  12. php 基础篇 php 进阶篇
  13. Java项目中的一些注意事项
  14. Linux_破解密码-营救模式
  15. PS2键盘扫描码:通码与断码
  16. 背水一战 Windows 10 (110) - 通知(Tile): secondary tile 模板之基础, secondary tile 模板之文本
  17. linux学习笔记-软件包的相关知识
  18. Unity接入Steamworks
  19. git 分支branch
  20. mysql 的 docker 镜像使用

热门文章

  1. 【Other】希腊诸神大全-中英文名称
  2. 【oracle】dblink创建
  3. ubuntu server vsftpd 匿名用户上传下载及目录设置
  4. NSURLSession 学习笔记
  5. es6-块级作用域let 和 var的区别
  6. Java的类名与文件名必须一致(转)
  7. TP3.2 APP_DEBUG=false关闭调试后访问不了。页面错误!请稍后再试~
  8. 解决 vue 的缩进问题 及 vue 的 sass 调用 mixin 函数
  9. systemctl的常用命令
  10. KnockoutJS + My97DatePicker b