1
database = mongo_connect()
un = str(session['username'])

database.game.insert({'host': session['username'],
    'player_list':[un]})

If i do this, then when I retrieve player_list, I get a list of unicodes. How can I make it so that I get a list of strings? Thanks

1
  • 1
    Why would you want strs instead of unicodes? Commented Mar 16, 2013 at 18:28

1 Answer 1

1

because mongodb stores data in bson format, and since bson is utf8-encoded, you'll get only unicode strings.

you can encode unicode into str anyway;

player_list = [x.encode('utf-8') for x in player_list]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.