python列表推导式的if-else
2024-08-27 13:46:24
a=[i for i in range(10) if i%2==0]
print(a)
a=[i if i%2==0 else 'qi' for i in range(10)]
print(a)
结果:
[0, 2, 4, 6, 8]
[0, 'qi', 2, 'qi', 4, 'qi', 6, 'qi', 8, 'qi']
最新文章
- Squirrel: 通用SQL、NoSQL客户端
- EasyUi – 2.布局Layout + 3.登录界面
- [转]Oracle 树操作(select…start with…connect by…prior)
- chubu
- 虚幻4以及DX12将允许开发者利用Xbox One的更多性能(转)
- C#UDP(接收和发送源码)源码完整
- I2C驱动程序
- JavaScript Invalid Date Verify
- 数据结构——UVA 1600 机器人巡逻
- Python基础(六)-内置函数
- 【转】TCP/IP协议中TCP和UDP的区别
- 【linux】mysql安装问题 g++: not found
- casio计算器计算统计数据
- Codeforces Round #514 (Div. 2) C. Sequence Transformation 思维构造
- 利用StateListDrawable给button动态设置背景
- texlive测试是否安装成功
- react native获取屏幕的宽度和高度
- 《Spring实战》-- 'cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element' 错误的解决办法
- here i am(歌手BryanAdams的歌曲)
- 【webpack】理解配置文件
热门文章
- UNP学习笔记(第十一章 名字与地址转换)
- Activity 事件以及如何得到新打开Activity关闭后返回的数据
- setTimeout()基础/setInterval()基础
- Cocostudio学习笔记(5) Text + TextAtlas + TextBMFont
- 封装CLLocationManager定位获取经纬度
- 跟我一起写 Makefile(一)[转]
- leetCode 84.Largest Rectangle in Histogram (最大矩形直方图) 解题思路和方法
- SkipList跳表(一)基本原理
- linux支持的machine-types
- linux下开启ftp的21号port