alex_bn_lee

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

03 2019 档案

【389】Implement N-grams using NLTK
摘要:Ref: Natural Language Toolkit Ref: n-grams in python, four, five, six grams? Ref: "Elegant n-gram generation in Python" Another method to output: 获取一段 阅读全文

posted @ 2019-03-28 14:30 McDelfino 阅读(186) 评论(0) 推荐(0) 编辑

【388】※ Some useful websites for learning Python
摘要:Ref: Python Tips 1. *args and **kwargs 2. Debugging 3. Generators 4. Map, Filter and Reduce 5. set Data Structure 6. Ternary Operators 7. Decorators 8 阅读全文

posted @ 2019-03-26 14:17 McDelfino 阅读(162) 评论(0) 推荐(0) 编辑

【387】Python format 格式化函数(以及 %)
摘要:参考:Python format 格式化函数 参考:python基础_格式化输出(%用法和format用法) # 保留小数点后两位 f'{3.1415926:.2f}' # 带符号保留小数点后两位 f'{3.1415926:+.2f}' f'{-1:+.2f}' # 不带小数 f'{2.71828: 阅读全文

posted @ 2019-03-21 14:53 McDelfino 阅读(234) 评论(0) 推荐(0) 编辑

【386】operator 的 itemgetter、slice、and_、or_
摘要:itemgetter 用来获取数组中指定索引的元素 slice 用来为列表切片,也是获取指定索引的元素 and_ 相当于 a & b,用来求两个集合的交集 可以联合 reduce 实现多个集合交集的计算 or_ 相当于 a | b,用来求两个集合的交集 可以联合 reduce 实现多个集合并集的计算 阅读全文

posted @ 2019-03-21 13:30 McDelfino 阅读(267) 评论(0) 推荐(0) 编辑

【385】itertools 的 product 和 chain 和 accumulate
摘要:参考:itertools模块 product 相当于返回两个集合中数据的所有组合可能 Examples from Eric Martin 例子2:二进制数三位数的所有可能 chain 就是合并成一个 iter accumulate 可以实现将可迭代对象进行累加的效果,形成一个新的可迭代对象 阅读全文

posted @ 2019-03-21 13:16 McDelfino 阅读(222) 评论(0) 推荐(0) 编辑

【384】reduce归纳、map映射、filter筛选 的用法
摘要:参考:4. Map, Filter and Reduce — Python Tips 0.1 documentation 参考:Python的functools.reduce用法 Map:映射,对于列表的每个元素进行相同的操作 filter:筛选,筛选列表中满足某一条件的所有元素 reduce:归纳 阅读全文

posted @ 2019-03-21 12:58 McDelfino 阅读(286) 评论(0) 推荐(0) 编辑

【383】defaultdict 相关用法
摘要:可以定义一个字典,可以添加默认值,int 为 0,list 为 [],set 为 {} int:默认值为 0 list,默认值为空列表,也可以用 append set:默认值为空集合 阅读全文

posted @ 2019-03-21 12:33 McDelfino 阅读(185) 评论(0) 推荐(0) 编辑

【382】利用 namedtuple 实现函数添加属性
摘要:namedtuple 能够实现类似类的效果,tuple 的元素可以通过属性的形式返回,如下所示: 因此若是想要让函数返回属性的效果,只需让函数的返回值是 namedtuple 即可,如下所示 阅读全文

posted @ 2019-03-21 12:24 McDelfino 阅读(283) 评论(0) 推荐(0) 编辑

【381】python 获取列表中重复元素的索引值
摘要:参考:获取python的list中含有重复值的index方法_python_脚本之家 核心思想:建立字典,遍历列表,把列表中每个元素和其索引添加到字典里面 阅读全文

posted @ 2019-03-19 07:50 McDelfino 阅读(7448) 评论(0) 推荐(0) 编辑

【380】python 获取列表排序后的索引列表
摘要:参考:Equivalent of Numpy.argsort() in basic python? - Stack Overflow 通过 enumerate 实现 阅读全文

posted @ 2019-03-19 06:37 McDelfino 阅读(4478) 评论(0) 推荐(0) 编辑

【379】pandas 说明
摘要:参考:Kaggle Pandas Tutorial Part 1 参考:Kaggle Pandas Tutorial Part 2 参考:Pandas速查手册 参考:pandas 官方 API pandas.Series:单列的 pandas.DataFrame:数据表格 ref: Pandas: 阅读全文

posted @ 2019-03-18 17:48 McDelfino 阅读(334) 评论(0) 推荐(0) 编辑

【378】python any() and all()
摘要:Reference: [1] Python all() - Python Standard Library [2] Python any() - Python Standard Library all() and any() 函数主要用于需要判断某个数组是不是都满足了某种条件,设置一个跟数组一样的 阅读全文

posted @ 2019-03-13 14:45 McDelfino 阅读(203) 评论(0) 推荐(0) 编辑

【377】only one element in a tuple
摘要:Recently I am doing the assignment of COMP9021. It is too difficult and it is about the Knight and Knave. While I tried to finish this assignment, how 阅读全文

posted @ 2019-03-11 07:53 McDelfino 阅读(139) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示