- 博客(9)
- 收藏
- 关注
原创 类的装饰器应用
def Typed(**kwargs): def deco(obj): for key,val in kwargs.items(): # obj.key=val setattr(obj,key,val) return obj return deco @Typed(x=1,y=2,z=3) #1....
2018-11-26 15:38:01 117
原创 python 描述符的应用
# def test(x): # print('===>',x) # # test('alex') # test(111111) class Typed: def __init__(self,key,expected_type): self.key=key self.expected_type=expected_type def ...
2018-11-26 13:46:04 123
原创 python 迭代器协议斐波那契数列
class Fib: def __init__(self): self._a=1 self._b=1 def __iter__(self): return self def __next__(self): if self._a > 100: raise StopIteratio...
2018-11-14 17:19:05 231
转载 python包标准类型和动态导入模块和多态和反射和授权
class List(list): def append(self, p_object): if type(p_object) is str: # self.append(p_object) super().append(p_object) else: print('只能添加字符串类型...
2018-11-12 09:34:20 207
原创 printf 输出字符串 需要加上 c_str()
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> using namespace std; int main(){ string s = "哈哈"; cout << s << endl; printf("a=%s", s.c_str()); ...
2018-11-05 11:46:09 2090
原创 python hashlib
import hashlib obj=hashlib.md5() # obj.update("admin".encode("utf8")) # print(obj.hexdigest()) #21232f297a57a5a743894a0e4a801fc3 obj.update("adminroot".encode("utf8")) print(obj.hexdigest())# ...
2018-11-01 16:30:23 209
转载 python configparser模块
# import configparser # # config = configparser.ConfigParser() #config={} # # # # # config["DEFAULT"] = {'ServerAliveInterval': '45', # 'Compression': 'yes', # ...
2018-11-01 16:10:21 156
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人