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?
- SyntaxError: unexpected EOF while parsing
- How to use filter, map, and reduce in Python 3
- Using prevNext Modx Addon
- converting time from UTC to CST
- :wq! command in vim
- how to set the background color of the status bar during the launching phase [duplicate]
- Use Gif Logo For Loading Screen In Kivy
- api-ms-win-crt-runtime-l1-1-0.dll is missing when opening Microsoft Office file [closed]
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- How can I make a time delay in Python? [duplicate]
- When is K 1024 and when is it 1000?
- What is a MIME type?
- Python – TypeError: ‘int’ object is not iterable
- Logitech/LGHUB Lua – Loop with break
- are there dictionaries in javascript like python?
- How can I convert MP3 file to a Base64 encoded string? [closed]
- Understanding The Modulus Operator %
- Dial pad to get phone number (with Android button images)
- How to open a file using the open with statement
- How is the AND/OR operator represented as in Regular Expressions?
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- Istio Ingress resulting in “no healthy upstream”
- Why is it not possible to fake an IP address?
- How to open a “-” dashed filename using terminal?
- Substring in excel
- What is a LAMP stack?
- How to install pip with Python 3?
- What is a sanity test/check
- What is the difference between rw+ and r+
- What is the difference between POST and PUT in HTTP?
- What is the difference between POST and PUT in HTTP?
- How to find Google’s IP address?
- What exactly is a VBO in OpenGL?
- What and where are the stack and heap?
- Convert bytes to a string
- ping response “Request timed out.” vs “Destination Host unreachable”
- Authentication versus Authorization
- What is a reverse shell?
- How does npm start work? What all processes are happening in the background?
- What is an instance variable in Java?
- What is the := operator?
- What is tail recursion?
- Discord music bot not working
- What does “:=” mean in Pseudocode? [closed]
- How can I represent an ‘Enum’ in Python?
- Why am I getting error for apple-touch-icon-precomposed.png
- Python – TypeError: ‘int’ object is not iterable
- No results found on kibana -> discover
- Import Error: No module named numpy
- Python3 – ModuleNotFoundError: No module named ‘numpy’
- What is Xpenology? Is it Linux related thing?
- Relative imports – ModuleNotFoundError: No module named x
- Python: ‘ModuleNotFoundError’ when trying to import module from imported package
- Relative imports – ModuleNotFoundError: No module named x
- Why do we need virtual functions in C++?
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to uninstall a package installed with pip install –user
- What is a CSRF token? What is its importance and how does it work?
- How do I upgrade the Python installation in Windows 10?
- Create blank image in Imagemagick
- not all arguments converted during string formatting.. NO % variables
- Official definition of CSCI (Computer Software Configuration Item)
- How do I use raw_input in Python 3
- Python Variable Declaration
- How could I ping @here in Discord.py?
- Relative imports in Python 3
- Python Math – TypeError: ‘NoneType’ object is not subscriptable
- Relative imports in Python 3
- What does %>% mean in R [duplicate]
- super() in Java
- Visual List of iOS Fonts?
- What is useState() in React?
- TCP vs UDP – What is a TCP connection? [duplicate]
- How do I copy folder with files to another folder in Unix/Linux? [closed]
- ssh : Permission denied (publickey,gssapi-with-mic)
- Eclipse IDE for Java – Full Dark Theme
- working of \n in python [duplicate]
- Pip freeze vs. pip list
- Amazon Linux: apt-get: command not found
- Google Calendar API event insert always return 404 “not found” error
- ssh connect Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)
- What’s the syntax for mod in java
- TypeError: list indices must be integers or slices, not list
- Best way to convert string to bytes in Python 3?
- What does the Java assert keyword do, and when should it be used?
- Best way to convert string to bytes in Python 3?
- What does the list() function do in Python?
- How to get rid of the “No bootable medium found!” error in Virtual Box? [closed]
- TypeError: not all arguments converted during string formatting python
- How do I fix a “Expected Primary-expression before ‘)’ token” error?
- Using getline() with file input in C++
- STDERR? What is it? What are its common uses?