Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert string to integer in dictionary python

# if you have string and integer
for item in list_of_dicts:
    for key, value in item.iteritems():
        try:
            item[key] = int(value)
        except ValueError:
            item[key] = float(value) # use here str(value)
 
PREVIOUS NEXT
Tagged: #convert #string #integer #dictionary #python
ADD COMMENT
Topic
Name
2+3 =