摘要: 问题 a = 0.215 b = 0.225 print round(a, 2) print round(b, 2) # 执行结果 0.21 0.23 0.215 在进行四舍五入时,保留的两位小数没有进1 0.225 在进行四舍五入时,保留的两位小数可以进1 原因 因为在 Python3 里面,ro 阅读全文
posted @ 2021-07-05 09:25 苟住,别浪 阅读(921) 评论(0) 推荐(0) 编辑
摘要: 比较两个嵌套字典的值是否相等,不相等,打印出错误value的key路径 #!/usr/bin/python # -*- encoding: utf-8 -*- def check_result(actual_result, expect_result, ignore=None): ''' 检查重启前 阅读全文
posted @ 2021-03-08 14:39 苟住,别浪 阅读(421) 评论(0) 推荐(0) 编辑
摘要: 多继承 1、在新式类中查找父类方法或属性,查找方式为广度优先 2、pyhton2经典类中,查找父类方法或属性,查找方式为深度优先 注:mro()方法可以查看类的继承顺序 python3新式类,继承查找顺序A > B > C 钻石继承 B和C同时继承A,B中没有func方法,会去找C,如果C也没有fu 阅读全文
posted @ 2020-06-04 21:31 苟住,别浪 阅读(767) 评论(0) 推荐(0) 编辑
摘要: 什么是装饰器:用于拓展原来函数功能的一种函数,目的是在不改变原函数名(或类名)的情况下,给函数增加新的 装饰器作用于最近的函数 在不修改 demo 函数的情况下,扩展 demo 功能,每次调用只能用 wrapper_demo 1 def demo(): 2 print('this is demo ! 阅读全文
posted @ 2020-05-13 23:13 苟住,别浪 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 官网链接:https://www.postgresql.org/download/linux/redhat/ 阅读全文
posted @ 2020-05-13 14:25 苟住,别浪 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 1、数据库 1)创建数据库 1 create database database_name; 2)创建一个数据库并检查是否存在,不存在才创建 1 create databases if not exists database_name; 3)创建一个数据库,并加上注释 1 create databa 阅读全文
posted @ 2019-10-07 16:49 苟住,别浪 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 以case开头end结尾 1、case when 条件1 then 取值1 else 不满足条件的取值 end 2、case 字段 when 条件值 then 满足条件后的结果 else 不满足条件的结果 end 3、case when 条件表达式1 then 满足条件后的结果1 else 不满足条 阅读全文
posted @ 2019-05-31 18:04 苟住,别浪 阅读(10284) 评论(0) 推荐(1) 编辑
摘要: python写入日志文件时日志内容重复写入:原因handler未移除,导致重复写入 问了度娘之后,大概搞明白了,就是你第二次调用log的时候,根据getLogger(name)里的name获取同一个logger,而这个logger里已经有了第一次你添加的handler,第二次调用又添加了一个hand 阅读全文
posted @ 2019-05-13 18:06 苟住,别浪 阅读(1944) 评论(0) 推荐(0) 编辑
摘要: # encoding: utf-8 import configparser import os class ReadConifg(): """读取配置文件""" def __init__(self, filename, filepath): os.chdir(filepath) # 将当前工作目录切 阅读全文
posted @ 2019-04-04 15:28 苟住,别浪 阅读(594) 评论(0) 推荐(0) 编辑
摘要: python 连接MySQL数据库,进行简单操作 一、连接MySQL数据库,关闭连接 二、进行查询操作 三、进行修改操作 对MySQL进行查询、修改、将对应的值提取出来 阅读全文
posted @ 2019-03-26 21:49 苟住,别浪 阅读(499) 评论(0) 推荐(0) 编辑