Python Stringio standard library Basics Learning

Source: Internet
Author: User
Tags python stringio

#标准库: Stringio provides the class file API text buffer
#作用: Can handle in-memory text, there are 2 different implementations: The CSTRINGIP version increases speed with C writing, Stringio provides portability with Python, and cstringio constructs large strings for better performance than other string connections
#示例
Try
From Cstringio import Stringio
Except
From Stringio import Stringio
#写入缓冲区
Out=stringio ()
Out.write (' buffer. ')
Print >>out, ' and so this. '
#读写
Print Out.getvalue ()
Print out.close () #dirsard buffer
Ipt=stringio (' Value buffer ')
#read from the buffer
Print Ipt.read ()
#这边使用read (), but you can also use the Readlin (), ReadLines () method, the Stringio class provides a seek () method that jumps through the buffer while reading the text, which is useful for rotation if a forward parsing algorithm is made
#StringIO官方标准地址: Https://docs.python.org/2.7/library/stringio.html?highlight=stringio#module-StringIO and https:/ /docs.python.org/2.7/library/stringio.html?highlight=stringio#module-cstringio

Python Stringio standard library Basics Learning

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.