Python learning 5, dictionary (with benefits, those who understand will understand naturally.)

1. Simple dictionary:

_author_ = "Happyboy"

info = {
    'stu1101': "TengLan Wu",
    'stu1102': "LongZe Luola",
    'stu1103': "XiaoZe Maliya",
}
print (info) #out of order in the dictionary 
print (info[ " stu1101 " ])
info[ " stu1101 " ] = " Mutolan " 
info[ " stu1104 " ] = " CangJingkong " #If there is, modify it   , if not, add 
print (info)

# del 
# del info["stu1101"] 
info.pop( " stu1101 " )   #The above two are delete instructions 
print (info)

print (info.get( " stu1102 " ))   #Safe access

print ( ' stu1103 '  in info) #Same as the above code
simple dictionary

 

2. There are benefits, complex dictionaries:

av_catalog = {
     " Europe and America " ​​: {
         " www.youporn.com " : [ " A lot of free, the largest in the world " , " General quality " ],
         " www.pornhub.com " : [ " A lot of free, also big " , " higher quality than yourporn " ],
         " letmedothistoyou.com " : [ " mostly selfies , many high-quality pictures " , " not many resources, slow update " ],
         " x-art.com ":[ "The quality is very high, really high" , " All charges, please bypass the diaos " ]
    },
    " Japanese and Korean " :{
         " tokyo-hot " :[ "I don't know how the quality is, I don't like Japanese and Korean fans anymore " , "I heard that there is a fee " ]
    },
    " Mainland " :{
         " 1024 " :[ " It's all free, it's great, good people have a safe life " , "The server is overseas, slow " ]
    }
}

av_catalog[ " Continent " ][ " 1024 " ][1] = " Can be mirrored in China "

av_catalog.setdefault("台湾",{"www.1100lu.com":[1,2]})

print (av_catalog)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324835529&siteId=291194637