From Python 3.0 changelog:
The StringIO and cStringIO modules are gone. Instead, import the io module and use io.StringIO or io.BytesIO for text and data respectively.
From the Python 3 email documentation it can be seen that io.StringIO
should be used instead:
from io import StringIO from email.generator import Generator fp = StringIO() g = Generator(fp, mangle_from_=True, maxheaderlen=60) g.flatten(msg) text = fp.getvalue()
Related Posts:
- Understanding the main method of python [duplicate]
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- PermissionError: [Errno 13] in Python
- Error in Python script “Expected 2D array, got 1D array instead:”?
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- Python FileNotFound
- How to draw a line with matplotlib?
- :wq! command in vim
- Understanding The Modulus Operator %
- What is the difference between rw+ and r+
- Convert bytes to a string
- ping response “Request timed out.” vs “Destination Host unreachable”
- What does “:=” mean in Pseudocode? [closed]
- Python – TypeError: ‘int’ object is not iterable
- Why do we need virtual functions in C++?
- Eclipse IDE for Java – Full Dark Theme
- Amazon Linux: apt-get: command not found
- What does the Java assert keyword do, and when should it be used?
- Difference between binary semaphore and mutex
- Convert bytes to a string
- ModuleNotFoundError: No module named ‘requests’. But ‘requests’ already installed
- Python Logic of ListNode in Leetcode
- TypeError: slice indices must be integers or None or have an __index__ method
- How to install xlrd in python3 library
- What is the difference between a strongly typed language and a statically typed language?
- ‘python3’ is not recognized as an internal or external command, operable program or batch file
- segmentation fault 11 in C++ on Mac
- How to append text to a text file in C++?
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- Pinging servers in Python
- Import error: No module name urllib2
- Echo newline in Bash prints literal \n
- Proper shebang for Python script
- AttributeError: can’t set attribute
- How to kill a running Spark application?
- Log to the base 2 in python
- fix java.net.SocketTimeoutException: Read timed out
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- Hidden field “ufprt” being added to Razor Umbraco Form – Why?
- Python: create a pandas data frame from a list
- Raise to power in R
- Python 3: UnboundLocalError: local variable referenced before assignment
- How to delete last item in list?
- Don’t understand this SyntaxError: illegal target for annotation
- APDU command to read Track1/track2 data from NFC card and MobileApp
- Using Queue in python
- Android setOnClickListener method – How does it work?
- Convert a CERT/PEM certificate to a PFX certificate
- What is process.env.PORT in Node.js?
- Reason for the exception java.lang.VerifyError: Bad type on operand stack
- python mpl_toolkits installation issue
- How do I create a popup window in tkinter?
- TypeError: ‘dict_keys’ object does not support indexing
- How do I get monitor resolution in Python?
- How to strip all whitespace from string
- Python Binomial Coefficient
- python3 TypeError: ‘function’ object is not iterable
- How to start from second index for for-loop
- pandoc document conversion failed with error 43 : pdflatex: The memory dump file could not be found
- ERROR: transport error 202: bind failed when starting Tomcat 7 in debug mode
- pandas equivalent of R’s cbind (concatenate/stack vectors vertically)
- How to check whether a Button is clicked by using JavaScript
- jQuery onclick not firing on dynamically inserted HTML elements?
- What is correct media query for IPad Pro?
- ModuleNotFoundError: No module named ‘seaborn’ in Python IDE
- Is there a ceiling equivalent of // operator in Python?
- Root mean square of a function in python
- Arithmetic Overflow in mips
- How to change angular port from 4200 to any other
- Getting DOM element value using pure JavaScript
- What is the difference between lemmatization vs stemming?
- Instagram how to get my user id from username?
- Checking to see if a string is an integer or float
- Procedural and non-procedural query language difference
- COM object that has been separated from its underlying RCW cannot be used
- Swift 2: !, ? -” Value of optional type “…” not unwrapped”
- How to know/change current directory in Python shell?
- What is a .meta file and why does Unity create them for all of my assets?
- How to use cmp() in Python 3?
- Center div on the middle of screen [duplicate]
- Error: No module named ‘fcntl’
- Python can’t find file
- Which function grows faster, exponential or factorial?
- How to calculate Internet checksum?
- Brackets.io in built support for TypeScript
- XML Error: Extra content at the end of the document
- Error: You need to include some adapter that implements __karma__.start method
- ggplot facet_wrap: At least one layer must contain all variables used for facetting
- how do I upgrade pip on Mac?
- Child theme on style.min.css
- Refresh admin page after woocommerce order received
- jquery anchor effect does not work properly
- Add link to php field text on wordpress form
- To remove rendering of menus and header, plugin or theme?
- How to filter http traffic in Wireshark?
- Vagrant / VirtualBox DNS 10.0.2.3 not working
- Dealing with HTTP w00tw00t attacks
- Multiple data centers and HTTP traffic: DNS Round Robin is the ONLY way to assure instant fail-over?
- Assign Public IP (not Elastic IP) after instance launched