This is what StringIO
(in Python 2) and io.BytesIO
in (in Python 3) are for.
More Related Contents:
- Correct way to write line to file?
- Writing a list to a file with Python
- Writing a Python list of lists to a csv file
- Rename multiple files in a directory in Python [duplicate]
- Merge PDF files
- How to read file N lines at a time?
- Python, Pandas : write content of DataFrame into text File
- Inline CSV File Editing with Python
- How to delete specific strings from a file?
- write() versus writelines() and concatenated strings
- Replace string within file contents [duplicate]
- IOError: [Errno 22] invalid mode (‘r’) or filename: ‘c:\\Python27\test.txt’ [duplicate]
- Batch Renaming of Files in a Directory
- How to solve “OSError: telling position disabled by next() call”
- An integer is required? open()
- using Python logger class to generate multiple logs for different log levels
- Python not recognising directories os.path.isdir() [duplicate]
- IOError: [Errno 13] Permission denied when trying to open hidden file in “w” mode
- How to read tokens without reading whole line or file
- How can I read large text files line by line, without loading them into memory? [duplicate]
- Python read() function returns empty string [closed]
- Open files in ‘rt’ and ‘wt’ modes
- Is pickle file of python cross-platform?
- How to append new data onto a new line
- Python file operations
- Automatically creating directories with file output [duplicate]
- What is the difference between rb and r+b modes in file objects [duplicate]
- How to write to a file without overwriting current contents? [duplicate]
- python write string directly to tarfile
- how to count the total number of lines in a text file using python