Initializing a dictionary in python with a key value and no corresponding values

前端 未结 8 1907
情深已故
情深已故 2021-01-30 19:29

I was wondering if there was a way to initialize a dictionary in python with keys but no corresponding values until I set them. Such as:

Definition = {\'apple\':         


        
8条回答
  •  孤独总比滥情好
    2021-01-30 20:02

    You can initialize the values as empty strings and fill them in later as they are found.

    dictionary = {'one':'','two':''}
    dictionary['one']=1
    dictionary['two']=2
    

提交回复
热议问题