摘要: 原因: python只允许一个**init** 函数构造类 法1:将init的参数改为不定长参数: 方法思路: 将__init__ 的参数改为不定长参数, 然后在__init__ 中通过判断参数的数量,进行不同的操作 class Rect: __length = 0 __width = 0 # 使用 阅读全文
posted @ 2022-06-01 20:07 kingwzun 阅读(6735) 评论(0) 推荐(0) 编辑
摘要: 知识点: python创建多个构造方法 使用classmethod 将init的参数设为可变类型,在init语句中判断 class Rect: __length = 0 __width = 0 def __init__(self, l, w): self.__length = l self.__wi 阅读全文
posted @ 2022-06-01 19:48 kingwzun 阅读(310) 评论(0) 推荐(0) 编辑
摘要: Filter过滤器简介 Filter被称作过滤器或者拦截器,其基本功能就是对Servlet容器调用Servlet的过程进行拦截,从而在Servlet进行响应处理前后实现一些特殊功能。 当浏览器访问服务器中的目标资源时,会被Filter拦截,在Filter中进行预处理操作,然后再将请求转发给目标资源。 阅读全文
posted @ 2022-06-01 16:59 kingwzun 阅读(36) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/g13197895299/article/details/123017413 解决方案: 阅读全文
posted @ 2022-06-01 16:24 kingwzun 阅读(270) 评论(0) 推荐(0) 编辑
摘要: from abc import ABCMeta, abstractmethod import math from webbrowser import BaseBrowser class Shape: __metaclass__=ABCMeta @abstractmethod def length(s 阅读全文
posted @ 2022-06-01 15:47 kingwzun 阅读(528) 评论(0) 推荐(0) 编辑
摘要: Python __ 面向对象基础 import math as m class Rect: l = 0.0 h = 0.0 z = 0.0 def __init__(self, l, h, z): self.l = l self.h = h self.z = z def length(self): 阅读全文
posted @ 2022-06-01 14:35 kingwzun 阅读(464) 评论(0) 推荐(0) 编辑
摘要: from cgi import print_arguments class Time: __hour=0 __minute=0 __second=0 #设置数据成员hour的值(采用12小时制),非法的输入默认为12; def setHour(self, h): if h>12 or h<0: se 阅读全文
posted @ 2022-06-01 11:08 kingwzun 阅读(573) 评论(0) 推荐(0) 编辑
摘要: 原文 定义类 class ClassName: #属性 . . . #方法 . . . 小样例: 代码里面的self作用相当于java中的this,表示当前类的对象,可以调用当前类中的属性和方法。 后面会详细说 class Point: x=0 y=0 def toString(self): ret 阅读全文
posted @ 2022-06-01 10:45 kingwzun 阅读(58) 评论(0) 推荐(0) 编辑
摘要: class Point: x=0 y=0 def __init__(self,xx,yy): self.x=xx self.y=yy def move(self,x1,y1): self.x+=x1 self.y+=y1 def toString(self): return "({},{})".fo 阅读全文
posted @ 2022-06-01 09:55 kingwzun 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 概述 Python标准库fractions中Fraction类 能够自动对分子和分母进行约分,当分子分母中有负号时,自动约分并最终将负号归于分子 导入 from fractions import Fraction 实例化 Fraction类实例可以由一对整数,一个分数,或者一个字符串构建而成。 # 阅读全文
posted @ 2022-06-01 09:37 kingwzun 阅读(384) 评论(0) 推荐(0) 编辑