上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 34 下一页
摘要: 继承 导出类自动获得基类的所有域和方法 private的域和方法导出类无法继承 创建导出类对象时,该对象会包含一个基类的子对象 Java会自动在导出类的构造器中插入对基类构造器的调用 调用基类构造器必须是你在导出类构造器中要做的第一件事 域的修饰关键字 public可被所有类访问 proteced对 阅读全文
posted @ 2021-03-25 21:14 code-G 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 抽象类 由抽象方法必须是抽象类 抽象类可以有非抽象方法 接口 接口里的域隐式的是static和final的 一旦某个类实现了接口,这个类就是个普通的类 接口中被定义的方法必须是public的 多重继承使用接口implements,接口继承接口使用extends 使用接口的核心原因是为了能向上转型为多 阅读全文
posted @ 2021-03-25 21:01 code-G 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 查询 import pymysql if __name__ == '__main__': # 创建连接对象 con = pymysql.connect(host="localhost", port=3306, user="xxxx", password="xxxx", database="db1", 阅读全文
posted @ 2021-03-10 16:54 code-G 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 一般形式 import re # 在helloworld中匹配hello # 返回匹配的obj对象 obj = re.match('hello','hello world') # 获取匹配结果 group(n)获取第n+1组所匹配的子串 pro = obj.group() print(pro) 匹配 阅读全文
posted @ 2021-03-10 16:21 code-G 阅读(58) 评论(0) 推荐(0) 编辑
摘要: complie(pattern[,flags]) 创建模式对象 search(pattern,string[,flags]) 在整个字符串中寻找模式,返回match对象或None match(pattern,string[,flags]) 从字符串的开始处匹配,返回match对象或None find 阅读全文
posted @ 2021-03-10 16:01 code-G 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 浅拷贝 from copy import * # 无论深浅拷贝都针对可变类型 num1 = 1 num2 = copy(num1) print(id(num1),id(num2)) # 数字。字符串,元组,都没有开辟新空间,都是指向同一个引用地址 list1 = [1,3,4,[1,2]] list 阅读全文
posted @ 2021-03-10 11:04 code-G 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 推导式创建生成器 genter = (i * 2 for i in range(3)) # value = next(genter) # print(value) # value = next(genter) # print(value) # value = next(genter) # print 阅读全文
posted @ 2021-03-10 10:54 code-G 阅读(69) 评论(0) 推荐(0) 编辑
摘要: with语句 # with语句简化文件操作,出错也会关闭文件 with open('abc.txt','r',encoding='utf-8') as file: file_data = file.read() print(file_data) 自写文件管理器 class File(object): 阅读全文
posted @ 2021-03-09 20:50 code-G 阅读(56) 评论(0) 推荐(0) 编辑
摘要: property的装饰器方式使用 class Person(object): def __init__(self): self.__age = 0 @property # 把age方法当属性使用,获取age属性时会调用下面的方法 def age(self): print('获取年龄属性') retu 阅读全文
posted @ 2021-03-09 19:34 code-G 阅读(59) 评论(0) 推荐(0) 编辑
摘要: class person(): # 初始化要装饰的函数 def __init__(self,fn): self.__fn = fn # 在call方法中使用目标函数 def __call__(self, *args, **kwargs): print('呵呵') self.__fn() @perso 阅读全文
posted @ 2021-03-09 19:24 code-G 阅读(69) 评论(0) 推荐(0) 编辑
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 34 下一页