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. Vue.use

    不管是对象还是函数install 是Vue.use()必须要有的方法 否则无法使用(Vue.use(MintUI))但axios 不需要Vue.use(axios) 可以直接使用 因为axios没有i ...

  2. mac 支持rz sz

    安装 lrzsz brew install lrzsz 配置 iTerm2 安装完成后我们需要在 iTerm2 中使用的话,还需要一些配置 进入到 /usr/local/bin 目录下,下载两个脚本文 ...

  3. matplotlib系列——饼图

    import matplotlib.pyplot as plt import numpy as np import matplotlib import sys 1.主体函数 #饼图 def die(l ...

  4. [FW]修复ubutnu12.04+win7的grub2引导

    [转]修复ubutnu12.04+win7的grub2引导 原文位置:http://wenku.baidu.com/view/b6b7c9926bec0975f465e2f8.html ps:我使用的 ...

  5. 中文字符集编码unicode,gb2312,cp936,GBK,GB18030介绍

    概要: UTF-8的一个特别的好处是它与ISO- 8859-1完全兼容,可以表示世界上所有的字符,汉字通常用3个字节来表示.GB2312的code page是CP20936.GBK的code page ...

  6. ftp搭建记录

    1.安装vsftpd的rpm包 rpm -ivh vsftpd-2.0.5-16.el5_4.1.i386.rpm 使用YUM命令安装 yum install vsftpd -y. 2.ftp命令 s ...

  7. css的9个常用选择器

    1.类选择器(通过类名进行选择) <!DOCTYPE html> <html> <head> <title></title> </he ...

  8. 一、Vue分页实现

    一.Vue分页实现 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equ ...

  9. Failed to resolve com.android.support:support-compat:25.4.0

    3down votefavorite   I am trying to include this library to my project by adding compile 'jp.wasabee ...

  10. Es学习第一课,了解基本功能和概念

    Elasticsearch作为这几年最流行的搜索引擎,越来越多的互联网企业都在采用它:作为java开发者来说,如果想进一步提高自己能力,同时也为了能够在实际工作中遇到搜索.存储问题多一个解决方案,学习 ...