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 8035381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:17:29+00:00 2026-06-05T02:17:29+00:00

I am using python and receiving data about a user by using the Twitter

  • 0

I am using python and receiving data about a user by using the Twitter api. What I get is a json encoded dict of attributes. For example

{

"id": 123456789,

"name": "ととり~む",

"screen_name": "somescreenname",

"description": "こんにちは♪ キャラ的にはこなたですが好きな子はつかさな私です。 ゲーム・漫画・アニメならなんでも好きです。 気が合う方はよろしくお願いします。 ",

}

Note: This is not the exact dict that I receive, but summarized for the question.

Some of my users have their data in another language, supposingly Japanese. I want to save the “name” of my user. When I use:

data["name"].encode('utf8')

I still end up losing some of the characters like this  ̄チᄄ ̄チᄄ ̄ツハ￯ᄑ゙ ̄ツタ. I don’t want to lose any data, what is the best mechanism I can apply here?

  • 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-05T02:17:30+00:00Added an answer on June 5, 2026 at 2:17 am

    I think you’ll find you’re not actually losing any data. You should be able to do:

    data['name'].encode('utf8').decode('utf8') 
    

    and get back the original string. You can write the intermediate bytes object to disk, and read it back in later and decode it to the same effect.

    What you seem to be worried about is the squares and other nonsense that come up when you print the encoded string – this is almost certainly a display issue, rather than data loss. Probably your terminal is attempting to interpret the bytes in a different encoding, resulting in Mojibake. As long as you are careful to keep your encodings straight in your program, this won’t cause you issues – just check that you can do the round-trip above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python module re, how to get the equivalent of the \w (which matches
(Using Python 3.2, though I doubt it matters.) I have class Data , class
I am in trouble with the bing's json api. Here is the json data
Attempting to build .exe using py2exe: python setup.py py2exe , receiving error: ImportError: No
I am receiving web response in different encoding using python and my expected output
Using python I'm parsing several strings. Sometimes the string has appended several semicolons to
Using Python how do you reduce a list of lists by an ordered subset
Using Python, I want to know whether Java is installed.
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
Using Python I would like to find the date object for last Wednesday. I

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.