How do I remove u chars from the following dictionary?
{u'name': u'A', u'primary_key': 1}
This data is coming from Mongo Database find() query
so that it looks like
{'name': 'A', 'primary_key': 1}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Some databases such as Sqlite3 let you define converter and adapter functions so you can retrieve text as str rather than unicode. Unfortunately, MongoDB doesn’t provide this option for any of the commonly needed types such as str, decimal or datetime:
Having eliminated Mongo options, that leaves writing Python code to do the conversion after the data is retrieved. You could write a recursive function that traverses the result to convert each field.
As a quick-and-dirty alternative, here is a little hack that may be of use: