- 博客(302)
- 资源 (4)
- 收藏
- 关注
原创 #p45689y2 python 使用__setattr__实现属性私有初步实验及需要注意的要点
2.在原先属性赋值时 如self.name self.__dict__[""] 中括号里必须为必须为'name'字符串形式 否则会认为是变量 出错。1.实验结果__setattr__中对任何self属性左赋值都将再次调用__setattr__会导致无穷递归循环。所以类中所有有关self的赋值 都要改为self.__dict__[" "] 形式。self.name->> self.__dict__['name'] 形式。
2022-09-14 22:54:06
420
原创 #p46456y1 类中 __iter__重载实现同时保有多个独立迭代器
'''目的:改进类中__iter__函数使其支持同一时间维持多个有活性的独立的迭代器'''self.x=0self.x+=1'''输出:1 i1|1 i2|2 i1|2 i2|3 i1|4 i1|3 i2|4 i2|1 i3|2 i3|3 i3|4 i3|结论:同时维持多个独立的新活性的迭代器 所以可以对同一对象进行嵌套循环对于迭代行为 先取对象的迭代器 之后执行其中的__next__方法''''''
2022-09-12 21:35:11
335
原创 解决pycharm无法使用install package
可以直接将包含该包的\Lib\site-packages 这个文件夹复制下来。我想安装requests 包 而事实是 我之前已经使用pip下载好了。之后替换新项目的 \venv\Lib下的site-packages。相当于不是解决这个bug,但是提供了一种绕开该bug的方式。这样我也能拿着pip 从cmd安装包再通过复制来续命了。当然直接从setting里下载失败这个bug还需要再看看。如果你已经下载好了包,只是无法识别。之前是这个情况啥也没有。之后再打开就可以正常运行了。而且这些包也识别过来了。
2022-09-02 19:30:32
2273
2
原创 如何将flv文件转为mp4文件?一个简单的解决办法
看到有要用python的但是感觉有点复杂解决办法1.打开b站 2.下载必剪app 3.导入flv到必剪 4.点导出为mp4 即可杀鸡就要用牛刀 哈哈
2022-05-27 22:24:33
896
1
原创 Py05 列表特定操作 Python推导语法 嵌套
F1 列表的特定类型操作1.Python的列表与其他语言的数组类似但是强大的多,因为列表没有固定类型的约束。2.列表没有固定大小,我们可以按需要进行增加或减小列表大小。>>>L=[1,'ab',1.23]>>>L.append('qx')>>>L[1, 'ab', 1.23, 'qx']>>>L.pop(0)1>>>L['ab', 1.23, 'qx']>>>L.pop(
2022-05-26 10:08:49
391
原创 Py02 python中的交互式命令行模式 、脚本、导入、重载、运行
python中的交互式命令行模式 、脚本、导入、重载、运行 import from exec dir
2022-05-13 22:15:44
1893
转载 pycharm,使用python console报TypeError: an integer is required (got type bytes)的解决方法(python3.8)
解决办法,我就不复制了参考pycharm,使用python console报TypeError: an integer is required (got type bytes)的解决方法(python3.8)_Wwwwhy_ 的博客-优快云博客
2022-05-13 16:27:55
3510
原创 debug_py TypeError: reload() argument must be a module
TypeError: reload() argument must be a module
2022-05-13 15:47:54
653
原创 22考研经验
没更新已经一年了,考研没什么心情再写博客,这一年考的中科院某所成功上岸计算机学硕,初试成绩,总成绩都是第一名,本篇博客是个人经验,本人也是跨考,复试没优势凭着高出第二名35分的初试成绩才最后总成绩第一名,如果能帮上大家点忙,我很高兴。一.数学一我用的书是最厚的那本李范全书,因为本科数学没看视频,一章章看再做后面的题,最后到了10月份才过完一轮,之后就是真题。定下计划就要坚持完成这样进度上才能跟得上,建议证明题不要先管,因为这个不是说你做个一两道就能培养起感觉的,说白了费力不讨好的题目,最后总结一
2022-04-07 18:24:55
663
2
原创 pat 2020秋 第二题
400 300 200 500 400 300 200 200 200 3007-2How Many Ways to Buy a Piece of Land(25分)The land is for sale in CyberCity, and is divided into several pieces. Here it is assumed that each piece of land has exactly two neighboring pieces, except the fir.
2021-03-06 11:32:59
370
转载 pat 复习 2020秋季 逻辑题交错比较
7-1Panda and PP Milk(20分)PP milk (盆盆奶)is Pandas' favorite. They would line up to enjoy it as show in the picture. On the other hand, they could drink in peace only if they believe that the amount of PP milk is fairly distributed, that is, fatter pa
2021-03-06 10:54:36
307
原创 pat 秋 Professional Ability Test
7-4Professional Ability Test(30分)Professional Ability Test (PAT) consists of several series of subject tests. Each test is divided into several levels. Level A is a prerequisite (前置要求) of Level B if one must pass Level A with a score no less than SSS
2021-03-05 22:59:19
1110
原创 DFS
如何写出dfs1.判断需要用dfs的情况明显树、图时不明显 _些实际的凑东西 模拟的时候 比较明显的情况有回溯时 在前个不变的情况下下一个不符合则倒回到上一个结点再选其他的2.当确定需要dfS时考虑1.阶段是什么各个阶段 一般为前后的递推主参数2.交叉路口是什么 (可选则的是什么)for循环用3.每个交叉路口可供选择的集合是什么 模拟要自己处理准备个阶段的集合4.终止条件是什么5.需不需要标记 需不需要去标记6.需不需要存...
2021-03-04 11:49:32
226
1
原创 pat 冬季第4题
掏钱买的考了一下最后一个题目大半天编一点编一点的感觉总是到不了头就睡觉去了 太困了 然后又搭上了晚上 看别人的总感觉思路虽然差不多但是我们实际处理差距还是很大的所以自己debug自己的代码 最后过了样例 感觉应该是对的不想再花一份钱弄一下了 有钱的老哥帮我弄一下看看对不对告诉我一下呗C:\Users\Administrator\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\TempState\Downloads\P...
2021-03-03 22:30:52
248
1
原创 pat 14复习必记模板
1、连通分量 图树 最深根1021#include<bits/stdc++.h>using namespace std;vector<int> ans1;int maxle=-1;vector<int> aa[10010];int visit[10010];void dfs(int root,int le){ //end visit[root]=1; if(le>maxle){ maxle=le;//maxle忘记更新 ans1
2021-02-27 17:41:04
208
1
原创 pat 复习 13 字符串处理剩余
//1082 挺复杂的字符串处理 #include<bits/stdc++.h>using namespace std;string numw[] ={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};string danwz[] ={"ge","Shi","Bai","Qian","Wan","Yi"};int a[]={1,10,100,1000,10000,100000,1000000,10000000,10000.
2021-02-20 23:52:48
316
原创 pat 复习 12 字符串处理
1001#include<bits/stdc++.h>using namespace std;int main(){ long long _1,_2,_3; scanf("%lld%lld",&_1,&_2); _3=_1+_2; string _4=to_string(_3); reverse(_4.begin(),_4.end()); int cnt=0; string ans=""; for(int i=0;i<_4.size();i++){
2021-02-19 22:55:57
195
原创 pat-复习10 11 平方映射 堆排序 归并排序 快速排序 直接插入排序的比较 二分查找
平方映射//1078 平方探测 #include<bits/stdc++.h>using namespace std;bool isprime(int n){ if(n<=1) return false; for(int i=2;i<=sqrt(n*1.0);i++){//<= 4.5 4本来可以<就漏掉了 if(n%i==0) return false; } return true;}int main(){ int ms,n,_1; s
2021-02-18 23:01:30
169
原创 pat-复习09 分数四则运算最后一道 素数 素因子分解 two pointer 链表
//1088 特意提到long int 相乘有可能超范围,所以当浮点错误时改用long long试一试 #include<bits/stdc++.h>using namespace std;int gcd(long long int a,long long int b){ if(b==0) return a; else gcd(b,a%b);}struct fra{long long int up,dowm;};fra reduction(fra a){ if(a.dow.
2021-02-16 23:48:40
168
原创 pat-复习08 大整数相加 分数运算部分
//1024 既然已经注意到是大整数相加了下面还用int 求和 to_string 这合适吗,不合适,数组也可以reverse 大整数相加千万不要在中途中再用整数赋值 否则大整数就白写了 #include<bits/stdc++.h> using namespace std; struct bign{ int d[1000]; int len; bign(){ memset(d,0,sizeof(d)); len=0; } }; /*bign ...
2021-02-16 00:16:36
1223
2
原创 pat-07排序部分stl应用
//1022 #include<bits/stdc++.h>using namespace std;//除了要注意换行符的吸收 还有注意年份的格式是%04d 编号的输出格式是%07d容易遗忘 map<string,set<int>>booktitle,author,keyword,publiser;//输出格式问题最后一定要点出来 map<int,set<int>>year; int main(){ int n; sca.
2021-02-14 23:10:20
103
原创 pat -06复习 并查集部分 以及排序前三道
//1118 并查集 #include<bits/stdc++.h>using namespace std;int fa[10009];int find(int x){ int a=x; while(x!=fa[x]){ x=fa[x]; } while(a!=fa[a]){ int z=a; a=fa[a]; fa[z]=x; } return x;}void unionn(int a,int b){ int f1=find(a); int .
2021-02-13 21:40:35
176
1
原创 pat-05复习 图部分剩余
//1111 //测试点二有问题 #include<bits/stdc++.h> using namespace std; vector<int> pred[510],pret[510],temp,temp1,ansd,anst; int distd[510],distt[510]; int a[510][510],t[510][510],visit1[510],visit2[510]; const int inf=1000000000; int ss,min..
2021-02-12 21:38:14
996
2
原创 pat-树剩余图部分03 04
//1009#include<bits/stdc++.h>using namespace std;struct node{int key,le,index; }; vector<int> in,post; vector<node> pre,lev[35]; int maxle=0; void dfs(int root,int inll,int inrr,int index,int le){ //end if(inll>inrr) re.
2021-02-10 23:07:30
181
原创 pat-树部分02
//1094#include<bits/stdc++.h>using namespace std;vector<int> v[110];int book[110] ;int maxle=0;void dfs(int root,int le){ //end book[le]++; if(v[root].size()==0){ if(le>maxle){ maxle=le; } return; } for(int i=0;i<v[ro.
2021-02-08 23:40:53
131
原创 pat 二刷树部分-01
//pat-143#include<bits/stdc++.h>using namespace std;vector<int> pre;map<int,int>ex;void lca(int a,int b){ int i=0; if(ex[a]==0&&ex[b]==0){ printf("ERROR: %d and %d are not found.\n",a,b); return; } else if(ex[a]==0){.
2021-02-07 22:46:30
165
原创 pat-1001
#include<bits/stdc++.h>using namespace std;int main(){ long long int a,b; scanf("%lld%lld",&a,&b); long long int sum=a+b; string q=to_string(sum); reverse(q.begin(),q.end()); int cnt=0; string ans=""; for(int i=0;i<q.size();i++).
2021-02-06 20:11:27
124
原创 pat-1005
#include<bits/stdc++.h>using namespace std;string aa[]={"zero","one","two","three","four","five","six","seven","eight","nine"};//一开始那个a与后面的string a重名了 int main(){ string a; cin>>a; long long int sum=0; for(int i=0;i<a.size();i++){ .
2021-02-06 19:50:29
93
原创 pat-1031
#include<bits/stdc++.h>using namespace std;char vv[100][100];int main(){ string a; cin>>a; fill(vv[0],vv[0]+100*100,' '); int n=a.size()+2; int k=n/3; int bot=a.size()-k*2,cnt=0;//应该是a。size()才对不是修饰过的n for(int i=0;i<k;i++){ vv[i.
2021-02-06 19:19:52
164
原创 pat-1037
#include<bits/stdc++.h>using namespace std;bool cmp1(int a,int b){ return a>b;} bool cmp2(int a,int b){ return a<b;}int main(){ int a,b,_1; scanf("%d",&a); vector<int>a1,a2,b1,b2; for(int i=0;i<a;i++){ scanf("%d",&am.
2021-02-06 16:09:30
104
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人