python核心编程-filter重构2
来源:互联网 发布:ghgvh软件 编辑:程序博客网 时间:2024/05/17 08:46
#!/usr/bin/env python# -*- coding: UTF-8 -*-'''filter第二次重构'''from random import randintallNums = []for eachNum in range(9): allNums.append(randint(1, 99))print allNumsprint [n for n in allNums if n%2]'''第三次重构'''from random import randint as riprint [n for n in [ri(1,99) for i in range(9)] if n%2]
输出:
D:\Python27\test>func15.py[47, 57, 75, 48, 41, 56, 46, 46, 1][47, 57, 75, 41, 1][15, 21, 19, 9, 89, 69]D:\Python27\test>
0 0
- python核心编程-filter重构2
- python核心编程-filter函数重构
- python核心编程-filter函数
- python核心编程2
- python核心编程-2
- Python核心编程多种方法实现过滤filter()
- python核心编程读书笔记2
- python核心编程读书笔记(2)
- python核心编程-练习2
- Python 核心编程习题2
- python核心编程2版 学习笔记
- Python核心编程读书笔记(2)
- 《python核心编程》整理(2)
- 《Python核心编程》第2章 习题
- python核心编程笔记(2)
- 《python核心编程》序列类型小结2
- python核心编程-可变参数2
- python 核心编程2 第十三章练习
- Clover好用的文件夹标签化工具推荐
- leetcode|Single Number(136)
- Android MPAndroidChart:动态添加统计数据线【8】
- C语言关键字
- 生活中有用的小技巧
- python核心编程-filter重构2
- hdoj Airport 5046 () 好题
- 无线路灯项目——STM32L低功耗相关
- 滚动数组
- 机器学习算法及应用领域相关的中国大牛
- ZYB's Biology解题报告
- W3C代码标准规范
- PS替换图标颜色
- [LeetCode]Minimum Height Trees