![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
weixin_45808716
这个作者很懒,什么都没留下…
展开
-
python 类和generator的一个小坑
当方法里关键字yield时,声明的变量没有创建,导致其他方法无法调用,应该next()一下,才能创建 class A(object): def __init__(self,name): self.name = name self.add() def add(self): self.b= 1 self.resp = "haha" while self.b<10: self.b+= 1原创 2022-04-17 15:01:45 · 527 阅读 · 0 评论 -
python 类变量和实例变量
python 类变化和实例变量原创 2022-04-16 20:48:40 · 545 阅读 · 0 评论 -
python 用pickle模块将原生数据类型写入文件
python写入txt文档时,不能将列表,字典类型写入,写入的txt读取只能是str,这在读取数据类型是非常麻烦的。 试用pandas写入csv文件,如果程序在运行,实时写入效率非常低,耗费时间。 pickle模块写入速度快,将原生类型写入pkl文件 import pickle #将字典写入pkl文件 #字典实例 dict= {"000858":[{"股票名称":"五粮液"},{"开盘价":"160"}]} for k,v in dict.items(): fr = open(k+".pkl","wb")原创 2022-04-09 21:42:52 · 2005 阅读 · 0 评论