摘要:
不用for循环,循环五次,取个随机值result = [random.randint(1,100) for x in range(5)]result = [[random.randint(1,100) for x in range(5)] for y in range(5)]参考:Python 的列表解析(list comprehension)和生成器表达式(generator expression)列表解析:语法:[expr for iter_var in iterable] 或 [expr for iter_var in iterable if cond_expr]说明:第一种语法:首先迭 阅读全文