上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 28 下一页
摘要: 1 注意,itertools.groupby假定输入的可迭代对象要使用分组标准排序;即使不排序,至少也要使用指定的标准分组各个元素。 1 #itertools.groupby函数的用法 2 import itertools 3 4 5 6 k1 = list(itertools.groupby('L 阅读全文
posted @ 2023-05-20 21:37 limalove 阅读(22) 评论(0) 推荐(0)
摘要: 1 combinations:组合数最少的;组合数的下限,重复没有意义(所以不存在AA,BB, CC 这种组合),元素的顺序也没意义(AB和BA是一种组合); product:返回笛卡尔积,组合数最多的,组合数的上限,重复和元素的顺序都有意义; combinations_with_replaceme 阅读全文
posted @ 2023-05-20 19:38 limalove 阅读(20) 评论(0) 推荐(0)
摘要: 1 1 import itertools 2 3 4 b = list(itertools.chain('ABC', range(2), [55,434,665,86])) 5 print('b:', b) # ['A', 'B', 'C', 0, 1, 55, 434, 665, 86] 6 7 阅读全文
posted @ 2023-05-20 18:08 limalove 阅读(13) 评论(0) 推荐(0)
摘要: 用于映射的生成器函数:在输入的单个可迭代对象(map和starmap函数处理多个可迭代的对象)中的各个元素上做计算,然后返回结果。[插图]表14-2中的生成器函数会从输入的可迭代对象中的各个元素中产出一个元素。如果输入来自多个可迭代的对象,第一个可迭代的对象到头后就停止输出。 aa 1 #演示ite 阅读全文
posted @ 2023-05-20 13:50 limalove 阅读(28) 评论(0) 推荐(0)
摘要: 用于过滤的生成器函数 阅读全文
posted @ 2023-05-20 12:56 limalove 阅读(26) 评论(0) 推荐(0)
摘要: Python的for循环本质上就是通过不断调用next()函数实现的,例如: for x in [1, 2, 3, 4, 5]: pass 实际上等价于: # 首先获得Iterator对象: it = iter([1, 2, 3, 4, 5]) # 循环: while True: try: # 获得 阅读全文
posted @ 2023-05-17 20:39 limalove 阅读(40) 评论(0) 推荐(0)
摘要: 安装Pandas pip install pandas; #查看版本号 pandas.__version__ 安装指定版本的Pandas模块 pip install pandas==1.4.3; 卸载pandas pip uninstall pandas; 原文链接:https://aistudio 阅读全文
posted @ 2023-05-15 14:55 limalove 阅读(5520) 评论(0) 推荐(0)
摘要: 从下可以看出 print(bool.__mro__) 阅读全文
posted @ 2023-05-14 17:08 limalove 阅读(20) 评论(0) 推荐(0)
摘要: 以为内置函数有很多呢 https://docs.python.org/3/library/functions.html 阅读全文
posted @ 2023-05-04 09:41 limalove 阅读(9) 评论(0) 推荐(0)
摘要: #示例10-11 计算整数0~5的累计异或的3种方式 import functools import operator #方法1: n = 0 for i in range(1,6): n ^= i print(n) #方法2: x1 = functools.reduce(lambda a, b: 阅读全文
posted @ 2023-05-03 14:58 limalove 阅读(55) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 28 下一页