I have the following response I am getting when I for loop through the following:
for col in ids:
print (format(col)),
print ("\n")
print type(ids[0])
I have a tuple that has element of different type: unicode, and int.
(u'0021401225', u'0021401203', u'0021401167', u'0021401148', u'0021401124', u'0021401092', u'0021401078', u'0021401066', u'0021401037', u'0021401023', u'0021401005', u'0021400995', u'0021400985', u'0021400964', u'0021400948', u'0021400924', u'0021400915', u'0021400900', u'0021400891', u'0021400854', u'0021400839', u'0021400821', u'0021400809', u'0021400800', u'0021400796', u'0021400766', u'0021400747', u'0021400743', u'0021400718', u'0021400711', u'0021400700', u'0021400681', u'0021400676', u'0021400658', u'0021400643', u'0021400626', u'0021400620', u'0021400599', u'0021400586', u'0021400570', u'0021400561', u'0021400547', u'0021400523', u'0021400503', u'0021400484', u'0021400479', u'0021400466', u'0021400429', u'0021400416', u'0021400401', u'0021400386', u'0021400370', u'0021400355', u'0021400336', u'0021400326', u'0021400308', u'0021400303', u'0021400281', u'0021400273', u'0021400253', u'0021400238', u'0021400211', u'0021400199', u'0021400186', u'0021400179', u'0021400159', u'0021400147', u'0021400133', u'0021400125', u'0021400098', u'0021400081', u'0021400066', u'0021400055', u'0021400022', u'0021400018')
I'm trying to store these values without the
u'
Because I can key off of these id's later in my program. But I just want to store them as integers which might look like the below:
[('0021401225','0021401203', '0021401167', '0021401148','0021401124', '0021401092', '0021401078', '0021401066', '0021401037', '0021401023')]
I would like to for-loop through them.
uprefix indicates you have an unicode character string, rather than a byte string. Both types will work equally well as a key. You can convert them to actual integers using the answer below but by usingintinstead ofstr.repr(some_tuple)as your storage format. You could usejsoninstead:json.dumps(some_tuple)