码迷,mamicode.com
首页 >  
搜索关键字:self    ( 14215个结果
importlib模块使用
一、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
通俗易懂之Python 面向对象中的方法及属性
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
PyTorch使用中需要注意的地方
参考博客: 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
Django框架11
内容回顾 forms组件源码 # 入口:form_obj.is_valid() ? # 校验字段和钩子函数的执行 ? # 报错提示 其实可以有两种方式(针对局部钩子函数) 1.self.add_error() 2.raise ValidationError() ? """ python源码里面使用最 ...
分类:其他好文   时间:2020-06-08 19:08:04    阅读次数:53
leetcode 每日一题 67. 二进制求和
逐位计算 思路: 遍历字符串,逐位加和,用一个变量记录是否产生进位。 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
101. 对称二叉树
思路:递归。 终止条件是两个节点都为空,return True; 或者两个节点中有一个为空,return False; 或者两个节点的值不相等,return False; class Solution(object): def isSymmetric(self, root): """ :type r ...
分类:其他好文   时间:2020-06-08 15:02:40    阅读次数:49
744. 寻找比目标字母大的最小字母
思路:二分法。 class Solution(object): def nextGreatestLetter(self, letters, target): letters = list(set(letters)) letters.sort() if target in letters: index ...
分类:其他好文   时间:2020-06-08 14:52:54    阅读次数:44
392. 判断子序列
class Solution(object): def isSubsequence(self, s, t): """ :type s: str :type t: str :rtype: bool """ if len(s) > len(t): return False elif len(s) == ...
分类:其他好文   时间:2020-06-08 14:51:19    阅读次数:47
1337. 方阵中战斗力最弱的 K 行
class Solution(object): def kWeakestRows(self, mat, k): """ :type mat: List[List[int]] :type k: int :rtype: List[int] """ power = [sum(line) for line ...
分类:其他好文   时间:2020-06-08 14:49:39    阅读次数:59
1111. 有效括号的嵌套深度
class Solution(object): def maxDepthAfterSplit(self, seq): """ :type seq: str :rtype: List[int] """ res = [] if not seq: return res depth, max_depth = ...
分类:其他好文   时间:2020-06-08 14:48:42    阅读次数:46
14215条   上一页 1 ... 61 62 63 64 65 ... 1422 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!