一、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
                             
                    
                        
                            
                            
                                    思路:递归。 终止条件是两个节点都为空,return True; 或者两个节点中有一个为空,return False; 或者两个节点的值不相等,return False; class Solution(object): def isSymmetric(self, root): """ :type r ...
                            
                            
                                分类:
其他好文   时间:
2020-06-08 15:02:40   
                                阅读次数:
49
                             
                    
                        
                            
                            
                                    思路:二分法。 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
                             
                    
                        
                            
                            
                                    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
                             
                    
                        
                            
                            
                                    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
                             
                    
                        
                            
                            
                                    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