![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python 学习记录
苏木不是木
知易行难
展开
-
python 求解水仙花数,自幂数
水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153)。水仙花数只是自幂数的一种,严格来说3位数的3次幂数才称为水仙花数。请输入整数m、n,中间以空格隔开:100 10000。附:其他位数的自幂数名字。四位自幂数:四叶玫瑰数。七位自幂数:北斗七星数。九位自幂数:九九重阳数。十位自幂数:十全十美数。三位自幂数:水仙花数。五位自幂数:五角星数。原创 2021-03-30 13:52:32 · 1187 阅读 · 5 评论 -
快速排序 - python3实现
先贴代码,后续补充说明# 快速排序算法 一 常规套路def qsort(lst, start, end): i = start j = end p = lst[start] while i < j: while i < j and lst[j] > p: j -= 1 while i < j and lst[i] < p: i += 1 if i < j and lst[i] == lst[j]: i += 1 else.原创 2020-12-22 15:01:21 · 118 阅读 · 1 评论 -
Python 返回两个或多个序列组成的并集
def unionall(*args): lst = [] for seq in args: for x in seq: if x not in lst: lst.append(x) return lstprint(unionall([1, 2, 3, 4], [2, 4, 5], [2, 4, 5, 6]))输出:[1, 2, 3, 4, 5, 6]原创 2020-11-05 13:22:36 · 184 阅读 · 0 评论 -
Python 匹配两个或多个序列的相同部分(交集)
def T-intersect(*args): lst= [] for x in args[0]: for other in args[1:]: if x not in other: break else: lst.append(x) return lstprint(Tintersect([1, 2, 3, 4], [2, 4, 5], [2, 4, 5, 6])).原创 2020-11-05 13:18:04 · 864 阅读 · 0 评论 -
No Module Named pip 问题
windows 可以用以下命令修复python -m ensurepip # pip修复python -m pip install --upgrade pip -i http://pypi.douban.com/simple --trusted-host pypi.douban.com # pip升级原创 2020-10-20 11:49:27 · 262 阅读 · 0 评论 -
Python 类调用方法
Python 调用方法有两种方式:1、instance.method(args...) # 实例名.方法名(参数)2、class.method(instance,args...) # 类名.方法名(实例名,参数)举个例子:class Super: def A(self,f): self.f=f print(self.f)class Replacer(Super): def B(self): print(...原创 2020-09-08 16:58:06 · 1444 阅读 · 0 评论