Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9307635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:26:13+00:00 2026-06-19T00:26:13+00:00

I am calling some sort of API which returns an object with three properties:

  • 0

I am calling some sort of API which returns an object with three properties:

obj.name
obj.id
obj.text

all of these could come in different encoding.

In order to output it correctly to my terminal, I am now doing

print obj.name.encode('UTF-8')
print obj.id.encode('UTF-8')
print obj.text.encode('UTF-8')

Is there a way I can simply do one time to set my default encoding to UTF-8?

I read some other post which suggested calling the sys.setdefaultencoding(‘UTF-8’), which is not available anymore in python 2.7.x

Please advise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:26:14+00:00Added an answer on June 19, 2026 at 12:26 am

    Normally Python detects the output encoding from the terminal settings; you can see what Python detected by running:

    import sys
    sys.stdout.encoding
    

    You really want to configure your terminal to specify the correct encoding if that doesn’t work for you; set the LC_CTYPE environment variable on POSIX systems for example.

    You can also force Python to use an encoding by setting the PYTHONIOENCODING environment variable:

    $ PYTHONIOENCODING=latin-1 python -c 'import sys; print sys.stdout.encoding'
    latin-1
    $  PYTHONIOENCODING=utf8 python -c 'import sys; print sys.stdout.encoding'
    utf8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason calling an NSPathControl object in a thread is causing crashes. -
Scenario: Retrieve some entities Update some properties on those entities You perform some sort
I have written a little helper function which performs some sort of drawing operations,
I am having some sort of problem with encoding in my ASP.NET HTTPHandler, which
I am looking for some sort of tool to help with calling Oracle stored
I'm calling some JavaScript from within my PHP code, but I want the second
I am trying to debug some exe in windbg. Now its calling some thirdparty
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:
I am writing some tools for our build system to enforce some strict calling
I have some problem with calling web service from flex. I have service with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.