随笔分类 -  Python

Python list的各种删除元素操作
摘要:转载https://note.nkmk.me/en/python-list-clear-pop-remove-del/ 这篇文章详细地记录了各种删除操作。 阅读全文
posted @ 2020-05-28 01:48 liuyihua1992 阅读(416) 评论(0) 推荐(1)
Python sort() 和 sorted() 的区别
摘要:sort()不会生成一个新的list,sort()改变的是list本身;而sorted()会生成一个新的list,sorted()不会改变list本身。 例如 list = [3, 2, 4, 1]print sorted(list) #输出是[1, 2, 3, 4]print list #输出是[ 阅读全文
posted @ 2020-05-27 07:14 liuyihua1992 阅读(194) 评论(0) 推荐(0)
Python判断字符串是否全是字母或数字
摘要:str.isnumeric(): True if 只包含数字;otherwise False。注意:此函数只能用于unicode string str.isdigit(): True if 只包含数字;otherwise False。 str.isalpha():True if 只包含字母;othe 阅读全文
posted @ 2018-09-15 02:58 liuyihua1992 阅读(21097) 评论(0) 推荐(1)
Python函数: any()和all()的用法
摘要:版权声明:本文为博主原创文章,未经允许不得转载 引子 平常的文本处理工作中,我经常会遇到这么一种情况:用python判断一个string是否包含一个list里的元素。 这时候使用python的内置函数any()会非常的简洁: any() 其实any函数非常简单:判断一个tuple或者list是否全为 阅读全文
posted @ 2018-09-14 02:28 liuyihua1992 阅读(2623) 评论(0) 推荐(0)
python使用xlrd和xlwt读写Excel文件
摘要:版权声明:本文为博主原创文章,未经允许不得转载。 安装模块 如果使用的是Linux系统,并且安装了pip,可以直接使用pip安装xlrd, xlwt: 也可以从官网下载源代码安装: https://pypi.org/project/xlwt/1.1.2/ https://pypi.org/proje 阅读全文
posted @ 2018-09-05 01:49 liuyihua1992 阅读(1228) 评论(0) 推荐(0)
读取json文件并把uft-8转换为ascii
摘要:版权声明:本文为博主原创文章,未经允许不得转载。 阅读全文
posted @ 2018-09-05 00:50 liuyihua1992 阅读(1332) 评论(0) 推荐(0)