生成字典和對字典根據“value”進行排序
from Helper.Tools import map_s d = {map_s[k]: v ** 2 for k, v in enumerate(range(10))} print(d) print(sorted(d.items(), key=lambda x: x[1], reverse=True))
Helper.Tools是我自己寫的一個工具包,map_s幫助平時快速生成一個字典,如下:
map_s = "abcdefghijklmnopqrstuvwxyz"
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/69442.html
標籤:Python
下一篇:05爬取約會吧美女全部照片
