Python
来源:互联网 发布:伴奏降调软件中文版 编辑:程序博客网 时间:2024/06/11 01:48
Python - 去除list中的空字符
method1:
while '' in index: index.remove('')
method2:
Python内建filter()函数 - 过滤list
filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素
def not_empty(s): return s and s.strip()res = filter(not_empty, ['1', '', '2', None, '3', ' '])# 结果: ['1', '2', '3']
阅读全文
0 0
- Python
- Python
- Python
- python
- Python
- PYTHON
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- python
- Python
- CNN 感受野大小计算
- 为什么构造器里面可以调用本类方法
- TensorFlow学习--入门之基本使用
- WatchOS系统开发大全(8)-WKInterfaceGroup
- 代码实现Android5.0的下拉刷新效果
- Python
- 图片格式转换--从bmp到yuv420p
- 轻松实现本地缓存的创建,读取,删除
- CCF CSP 201612-1 中间数(Java-100分)
- ART和Dalvik虚拟器的区别
- 575 Distribute Candies 分发糖果问题
- 连接池
- Cache-Control: no-cache和no-store
- 网络获取tablayout数据