using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 合并字典 { class Program { static void Main(string[] args) { Dictionary<int, string> dicA = new Dictionary<int, string> {…
1 列表生成式和生成器 from numpy import randoma = random.random(10000) lst = []for i in a: lst.append(i * i) # 不推荐做法 lst = [i * i for i in a] # 使用列表生成式 gen = (i * i for i in a) # 生成器更节省内存 2 字典推导式创建子集 a = {'apple': 5.6, 'orange': 4.7, 'banana': 2.8}da = {key: v…