Categories
Python Answers

How to set sys.stdout encoding in Python 3?

Spread the love

Sometimes, we want to set sys.stdout encoding in Python.

In this article, we’ll look at how to set sys.stdout encoding in Python.

How to set sys.stdout encoding in Python 3?

To set sys.stdout encoding in Python, we can call the sys.stdout.reconfigure method.

For instance, we write

sys.stdout.reconfigure(encoding='utf-8')

to call sys.stdout.reconfigure with the encoding argument set to 'utf-8'.

This will change the stdoud encoding to utf-8.

Conclusion

To set sys.stdout encoding in Python, we can call the sys.stdout.reconfigure method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *