https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/ 每日一题:递归 class Solution: def translateNum(self, num): if 0 <= num <= 9: retur ...
分类:
其他好文 时间:
2020-06-09 16:35:11
阅读次数:
61
1.4. Dependencies 1.4.1. Dependency Injection Dependency injection (DI) is a process whereby objects define their dependencies (that is, the other obj ...
分类:
编程语言 时间:
2020-06-09 16:33:25
阅读次数:
54
# 将罗马数字转换成整型# class Solution:# def romanToInt(self, s):# d = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}# num = 0# for i in rang ...
分类:
其他好文 时间:
2020-06-09 14:49:56
阅读次数:
57
Foundation 表单控制会自动设置为全局样式: 所有 <textarea>, <select> 及 <input> 元素宽度都为 100%,且带有外边距、内边距、阴影和鼠标移动效果。 实例 <form> Input: <input type="text" placeholder="Name"> ...
分类:
其他好文 时间:
2020-06-09 14:41:16
阅读次数:
64
装饰器 为私有属性提供getter和setter方法 原始实现代码: class Employee01: def __init__(self,name,age): self.__name = name self.__age = age def get_age(self): return self._ ...
分类:
编程语言 时间:
2020-06-09 12:37:37
阅读次数:
74
一、mon.py: class Mon: def __init__(self): pass def action(self, content): print('周一要{}'.format(content)) 二、tue.py: class Tue: def __init__(self): pass ...
分类:
其他好文 时间:
2020-06-09 10:02:43
阅读次数:
67
class A(): def walk(self): #实例方法,a = A()--a.walk() print('walking ') @staticmethod #静态方法, A().sta() def sta(): print('static func') @classmethod #类方法, ...
分类:
编程语言 时间:
2020-06-09 09:22:40
阅读次数:
67
参考博客: https://blog.csdn.net/u011276025/article/details/73826562/ 1. 把Label要转成LongTensor格式 self.y = torch.LongTensor(y) 完整使用代码如下: 1 class ImgDataset(Da ...
分类:
其他好文 时间:
2020-06-08 19:21:24
阅读次数:
92
内容回顾 forms组件源码 # 入口:form_obj.is_valid() ? # 校验字段和钩子函数的执行 ? # 报错提示 其实可以有两种方式(针对局部钩子函数) 1.self.add_error() 2.raise ValidationError() ? """ python源码里面使用最 ...
分类:
其他好文 时间:
2020-06-08 19:08:04
阅读次数:
53
逐位计算 思路: 遍历字符串,逐位加和,用一个变量记录是否产生进位。 class Solution: def addBinary(self, a: str, b: str) -> str: res = '' if len(a)<len(b): a,b = b,a temp = 0 for i in ...
分类:
其他好文 时间:
2020-06-08 19:04:04
阅读次数:
49