Python删除数组中数字的方式是什么,python数组,Python数组里有数字
Python删除数组中数字的方式是什么,python数组,Python数组里有数字
Python数组里有数字和单词,如何将数字去掉?
例如:
a = ['1', '2', 3, 'hello', 'hell323', '12hello']
想要输出:
a = ['hello', 'hell323', '12hello']
python为您准备了一系列友好的办法,楼主此需可用isdigit过滤,楼上已有回答,不再重复。
>>> dir(str) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
a = [v for v in a if not str(v).isdigit()]
编橙之家文章,
相关内容
- Python与R的数据接口调用问题,python数据接口,需要通过
- Python Pycurl7.19.7安装出错如何解决,pythonpycurl7.19.7,安装
- Python scrapy爬取数据异常求帮分析源码,pythonscrapy,由于
- Python scrapy模拟登陆知乎重定向问题,pythonscrapy,当我使
- Python3.4 import base64报AttributeRrror错误如何解决,,如图i
- Python 下载对应文件服务器的response该怎么写,pythonres
- xml文件很大python方法提取节点中多行文本怎么办,xml
- 说Python多线程是伪命题正确吗?,python多线程伪命题,我
- Python用mysql.connector select报错如何解决,,python中使用m
- Python什么方法可以将多行unicode字符串前u去除,pythonu
评论关闭