- 博客(13)
- 资源 (4)
- 收藏
- 关注
原创 Python:vscode编写python时提示Python(unresolved-import)
在引用自定义模块时,在代码无错的情况下,vscode提示Python(unresolved-import)可在vscode的setting.json中添加"python.analysis.disabled":["unresolved-import"]以消除该warning...
2019-10-29 14:51:16 8227 2
原创 Python:map、reduce、lambda的简单使用
from functools import reducedef normalize(name): return list(map(lambda x:x.capitalize(),name))def prod(L): return reduce(lambda x,y:x*y,L)def str2float(s): digit = {'0': 0, '1': 1,...
2019-10-24 15:11:19 317
原创 Python:装饰器简介(函数装饰类,类装饰函数,类装饰类)
函数装饰类def wrapClass(cls): def inner(a): print('class name:', cls.__name__) return cls(a) return inner@wrapClassclass Foo(): def __new__(cls,a): print("__new__方...
2019-10-21 19:36:20 226
原创 Python:装饰器简介(函数装饰函数)
def decorator(func): print('out') def inner(): print('inner start') func() print('inner end') return inner return inner@decoratordef function1(): pr...
2019-10-17 15:36:42 201
原创 Python:设计模式之工厂模式
class IWeapon(object): def info(self): raise NotImplementedErrorclass Sword(IWeapon): def info(self): print("This cold weapon is Sword")class Knigfe(IWeapon): def i...
2019-10-17 11:10:03 160
原创 Python:设计模式之抽象工厂模式
class IColdWeapon(object): def info(self): raise NotImplementedError def stick(self): raise NotImplementedErrorclass Sword(IColdWeapon): def info(self): print(...
2019-10-17 11:00:25 220
原创 Python:设计模式之简单工厂模式
class IWeapon(object): def info(self): raise NotImplementedErrorclass Sword(IWeapon): def info(self): print("This cold weapon is Sword")class Knigfe(IWeapon): def i...
2019-10-17 10:21:57 172
原创 Python:设计模式之装饰模式
class Character(object): def __init__(self, name): self._name = nameclass King(Character): def show(self): print("Name:", self._name)class CharacterDecorator(Characte...
2019-10-16 22:51:28 174
原创 Python:设计模式之命令模式
class Light(object): def on(self): print('Light on') def off(self): print('Light off')class TV(object): def on(self): print('TV open') def off(self): ...
2019-10-16 22:25:34 170
原创 Python:设计模式之观察者模式
#观察者模式之西游记师徒四人#被观察者class IMaster(object): def __init__(self): self._prentice_list = [] def name(self): raise NotImplementedError #收徒 def add_prentice(self, prentic...
2019-10-16 18:05:27 151
原创 Python:设计模式之适配器模式
class IStickWeapon(object): def weapon_type(self): raise NotImplementedError def use_stick_Weapon(self): print(f'Use:\t{self.weapon_type()}')class Sword(IStickWeapon): d...
2019-10-16 15:55:36 164
原创 Python:设计模式之策略模式
class IWeaponBahavior(object): def use_weapon(self): raise NotImplementedErrorclass SwordBahavior(IWeaponBahavior): def use_weapon(self): return "Sword"class KnigfeBah...
2019-10-15 16:56:30 194
原创 Python:python函数详解
Python函数形式def function_name(parm)->str: '''function declaration''' body return value说明function_name:函数名称function declaration:函数说明parm:参数body:函数体value:返回值参数– 必需参数/位置参数说明根据参数位置分配参...
2019-10-15 14:52:26 318
简单验证C++纯虚函数的机制
2020-08-17
pyTorch欠缺dll
2018-08-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人