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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:25:23+00:00 2026-05-26T15:25:23+00:00

I am saving my data into a dictionary and after saving it to the

  • 0

I am saving my data into a dictionary and after saving it to the dictionary I printed the data to see what it looks like and I see the unicode:

(u'520775', [[u'Kategori:2. divisjon fotball for herrer 2008']])
(u'754686', [[u'Kategori:Debutalbum', u'Kategori:Musikkalbum fra 1990', u'Kategori:Tre Sm\xe5 Kinesere-album']])
(u'381191', [[u'Kategori:Serierundene i Adeccoligaen 2007']])
(u'972597', [[u'Kategori:Tippeligaen 2011']])
(u'263001', [[u'Kategori:Musikkalbum fra 2003']])
(u'23037', [[u'Kategori:Luftforsvaret']])
(u'640060', [[u'Kategori:Deltagermedaljen', u'Kategori:F\xf8dsler i 1923', u'Kategori:Norske folkemusikere', u'Kategori:Norske trekkspillere', u'Kategori:Paul Harris Fellow', u'Kategori:Personer fra Vefsn kommune']])

I have the following code, I used the format option but it didn’t really work. What also confuses me is,when I print the id prior to saving it in dictionary, I see it without integer.

Here is the segment of the code,

for (pageId, pageData) in data['query']['pages'].iteritems():
            categoryTitles = [];
            idTitleDictionary[pageId] = [];
            print pageId;
            try:
                for category in pageData['categories']:
                    categoryTitles.append(category['title']);
                idTitleDictionary[format(pageId)].append(categoryTitles);

I am trying it figure how to encode it prior to saving it into a dictionary.

  • 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-05-26T15:25:24+00:00Added an answer on May 26, 2026 at 3:25 pm

    When you print a dict, or list, or tuple, repr is called on the items in the container, rather than str like when you print them directly, so you see the unicode escape codes.

    If you were to

    mydict = dict(((u'520775', [[u'Kategori:2. divisjon fotball for herrer 2008']]),
    (u'754686', [[u'Kategori:Debutalbum', u'Kategori:Musikkalbum fra 1990', 
                  u'Kategori:Tre Sm\xe5 Kinesere-album']]),
    (u'381191', [[u'Kategori:Serierundene i Adeccoligaen 2007']]),
    (u'972597', [[u'Kategori:Tippeligaen 2011']]),
    (u'263001', [[u'Kategori:Musikkalbum fra 2003']]),
    (u'23037', [[u'Kategori:Luftforsvaret']]),
    (u'640060', [[u'Kategori:Deltagermedaljen', u'Kategori:F\xf8dsler i 1923', 
                  u'Kategori:Norske folkemusikere', 
                  u'Kategori:Norske trekkspillere', u'Kategori:Paul Harris Fellow', 
                  u'Kategori:Personer fra Vefsn kommune']])))
    
    for key, value in mydict.iteritems():
        print key,
        for elem in value[0]:
            print elem + ',',
        print
    

    You’d see the strings encoded properly for your terminal. You don’t need to do anything to those strings to interpret the escape codes — everything is stored properly, it’s just how it’s being displayed.

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

Sidebar

Related Questions

I am trying to get a popup after saving some data into the database.
I have created a web service which is saving some data into to db.
I really like Xml for saving data, but when does sqlite/database become the better
What's the right way to go about saving data like Pages, Numbers and other
Is it possible to put some data into gnuplot right on it's prompt? Like
I have an application that is saving clob data into database. Suppose when I
I am facing the problem to insert the data into dictionary. It is not
When I am saving data into a table, extra spaces being added to the
I'm working with textbox in a datagrid. Before saving the data into the database,
I have created form using ModelForm but its not saving data into database. views.py

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.