list1 = ['122','2333','3444',' ','422',' ',' ','54',' ']

list1=[x.strip() for x in list1 if x.strip() != '']

Python删除列表中的空格的更多相关文章

  1. Python删除列表中元素

    Python中列表(list)是很常用的数据结构,删除列表中的元素有几种方法 列表的remove方法 lst = [1, 1, 3, 4] lst.remove(1) # lst->[1, 3, ...

  2. python——删除列表中的元素

    在python中,删除列表元素的方法有三种,分别为remove(),del(),pop()函数 (1)remove() >>> name = ['小明','小华','小红','小李' ...

  3. python删除列表中元素的方法

    删除列表中元素的三种方法-remove.pop.del 1 1.remove: 删除单个元素,删除首个符合条件的元素,按值删除 2 举例说明: 3 >>> str=[1,2,3,4, ...

  4. python删除列表中得重复得数据

    解决思想:将列表转换为 集合,利用集合删除重复数据得特性删除重复数据,然后将集合转换为列表 #删除列表中得重复元素 def delect_1 (lt): s = set(lt) lt = list(s ...

  5. Python 删除列表中的重复数据

    list0=['b','c', 'd','b','c','a','a'] 方法1:使用set() list1=sorted(set(list0),key=list0.index) # sorted o ...

  6. python 删除列表中的字典元素

    data={"} ,{"}]} print("before:\n\n",data,"\n\n") temp=- k= for i in da ...

  7. python删除列表中所有的空元素

    while '' in list: list.remove('')

  8. python中如何删除列表中的所有元素

    今天写代码的时候遇到一个小问题,Python中要删除列表中的所有元素.Python本身就提供了pop.remove.del这些删除的函数.我想着用循环实现,结果很麻烦.几番周折上了stackoverf ...

  9. for循环删除列表中元素遇到的漏删的问题(python)

    问题描述:python中通过for循环来删除列表中的两个相邻的元素,存在漏删的问题 比如说下面的例子,准备删掉2和3,但是结果是2删掉了,3没删掉 是因为把2删掉后3的下标就变成了1,但是原本下标为1 ...

随机推荐

  1. .NET/VB.NET: solving the error “The system cannot find the file specified.” “\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.vb”

    Source Link Bumped into this error a while ago in Visual Studio 2010: Kind Error Number 80 Descripti ...

  2. jmeter 线程组之间传递动态变化的变量值

    http://www.51testing.com/html/01/n-3725501.html https://www.jianshu.com/p/73832bae65af https://blog. ...

  3. W3C、MDN及html常用标签介绍

    W3C 万维网(World Wide Web)是作为欧洲核子研究组织的一个项目发展起来的,在那里 Tim Berners-Lee 开发出万维网的雏形.Tim Berners-Lee- 万维网的发明人和 ...

  4. ret/retn人为改变执行地址

    1.CALL和RET/RETN是一对指令,CALL把返回地址压入堆栈,RET/RETN把返回地址从堆栈取出,然后将IP寄存器改为该返回地址.  2.不使用CALL,而是人为地把地址放入堆栈即可实现.如 ...

  5. C++大整数类模板

    参考 :http://172.21.85.56/oj/resource/reportdetail?report_id=1678 支持 =.abs().pow().+=.-= *=./=.%=.+.-. ...

  6. Windows OS PathTooLongException 转摘自http://www.cstruter.com/blog/308

    When I told one of my developer friends that I am going to write a post about the PathTooLongExcepti ...

  7. C中整数的溢出

    /** * 整数的溢出 */ #include <stdio.h> int main(int argc, char *argv[]) { short i = -24; // 将-24以无符 ...

  8. html input标签 要求只能输入纯数字

    在input标签添加以下代码即可 oninput = "value=value.replace(/[^\d]/g,'')" <input type="text&qu ...

  9. notepad++编辑软件

    官网:http://notepad-plus-plus.org/ 官网截图(2015/4/29): 版本: Notepad++ 6.7.7 下载地址:http://notepad-plus-plus. ...

  10. linux随笔-06

    用户身份与文件权限 用户身份与能力 Linux系统的管理员之所以是root,并不是因为它的名字叫root,而是因为该用户的身份号码即UID(User IDentification)的数值为0. 在Li ...