Reputation: 1567
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
Upvotes: 1
Views: 1247
Reputation: 11543
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]
Upvotes: 1