I hate that I have to ask such a basic question, but I can't seem to get the split method to work in python.
I have a dictionary, when I print it, it looks like:
data_dict = <QueryDict: {u'ids': [u'1012,738'], u'ct': [u'9']}>
I want to create an array of id objects from the 'ids' list, as in:
ids = [1012, 738]
It appears that the list 'ids' is really just a string of ids separated by commas, so I tried:
id_string = data_dict['ids']
ids = id_string.split(',')
for id in ids:
print(id)
Nothing prints. Then I thought, perhaps the u' means its not a string and I need to convert it to a string first to get split to work, so I tried:
id_string = data_dict['ids']
id_string = str(id_string)
ids = id_string.split(',')
for id in ids:
print(id)
Nothing prints. Not sure what I am doing wrong.