Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert dictionary keys to int python

d = {'1':'145' , '2':'254' , '3':'43'}
d = {int(k):int(v) for k,v in d.items()}#convert both keys and values to int
>>> d
{1: 145, 2: 254, 3: 43}
Comment

PREVIOUS NEXT
Code Example
Python :: flask development mode 
Python :: requirements file generate django 
Python :: tkinter center frame 
Python :: mean deviation python 
Python :: how to order ints from greatest to least python 
Python :: trigonometry in python 
Python :: check key pressed pygame 
Python :: determinant of a matrix in python 
Python :: change dataframe column type 
Python :: python how to unnest a nested list 
Python :: PySpark columns with null or missing values 
Python :: send email python 
Python :: How to develop a TCP echo server, in Python? 
Python :: float number field django models 
Python :: python degrees to radians 
Python :: python tkinter clear textbox 
Python :: python roll a die 
Python :: get eth balance python 
Python :: remove grid in plt 
Python :: input stdout python 
Python :: django python install 
Python :: pandas lambda if else 
Python :: how to take user input in a list in python 
Python :: get text from url python last slash 
Python :: flatten a list of list python 
Python :: run every minute python 
Python :: how to write words on any other apps in python 
Python :: python how often character ins tring 
Python :: How to get key value list from selection fields in Odoo 10 
Python :: python join list with comma 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =