如何判断二叉树是否对称?
摘要:请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。 class Node(): def __init__(self,val): self.val = val self.lchild = None self.rchild = None cla
阅读全文
posted @
2020-05-28 20:17
仙人小麦
阅读(328)
推荐(0)
二叉树的功能实现
摘要:# 树的单个结点 class Node: def __init__(self,elem): # 结点数据 self.elem = elem # 左子树和右子树 self.lchild = None self.rchild = None # 二叉树的实现 class my_tree: # 初始化空树
阅读全文
posted @
2020-05-24 11:56
仙人小麦
阅读(216)
推荐(0)
单链表,双向链表,单向循环链表的功能实现
摘要:单链表的功能实现 # 定义链表的单个结点 class Node(): # 构造方法初始化结点 def __init__(self, elem): # 初始化数据区 self.elem = elem # 初始化链接区 self.next = None # 定义单链表 class single_link
阅读全文
posted @
2020-05-24 11:50
仙人小麦
阅读(326)
推荐(0)
栈,队列,双端队列 功能实现
摘要:# 栈的功能实现 Stack() 创建一个新的空栈 push(item) 添加一个新的元素item到栈顶 pop() 弹出栈顶元素 peek() 返回栈顶元素 is_empty() 判断栈是否为空 size() 返回栈的元素个数 class Stack: # 初始化空栈 def __init__(s
阅读全文
posted @
2020-05-24 11:36
仙人小麦
阅读(237)
推荐(0)
timeit 性能测试
摘要:1. timeit模块 可以用来测试一小段Python代码的执行速度。 计时器类:class timeit.Timer(stmt='pass', setup='pass', timer=<timer function>) Timer是测量小段代码执行速度的类 stmt:是要测试的代码语句(statm
阅读全文
posted @
2020-05-24 11:22
仙人小麦
阅读(282)
推荐(0)
冒泡排序,选择排序,插入排序,希尔排序,归并排序,快速排序 实现
摘要:1.冒泡排序 # 优化版 优化有序的情况,最优时间复杂度O(n) def bubble_sort(alist): # 外层循环控制比较几轮 n = len(alist) for j in range(n - 1): # 定义计数器 count = 0 # 内存循环控制交换 # -j是不再换已经排好的
阅读全文
posted @
2020-05-22 21:42
仙人小麦
阅读(375)
推荐(0)
异步爬虫组件
摘要:import time,requests from multiprocessing.dummy import Pool # 同步 # urls = [ # "http://127.0.0.1:5000/jay1", # "http://127.0.0.1:5000/jay2", # "http://
阅读全文
posted @
2020-05-18 22:26
仙人小麦
阅读(198)
推荐(0)
爬虫之识别验证码组件
摘要:#超级鹰提供的示例代码 #!/usr/bin/env python # coding:utf-8 import requests from hashlib import md5 class Chaojiying_Client(object): def __init__(self, username,
阅读全文
posted @
2020-05-18 20:53
仙人小麦
阅读(210)
推荐(0)
python常见命令
摘要:1,导出项目中所用到的模块pip freeze > requirements.txt2. .gitignore文件不生效git rm -r --cached .再重新提交 git remote add origin https://github.com/WuPeiqi/pondo.git 3. #
阅读全文
posted @
2020-05-16 21:43
仙人小麦
阅读(267)
推荐(0)
py 文件设置编码
摘要:转载脚本之家 如果要在python2的py文件里面写中文,则必须要添加一行声明文件编码的注释,否则python2会默认使用ASCII编码。(python3已经没有这个问题了,python3默认的文件编码是UTF-8) 必须将编码注释放在第一行或者第二行,一般来说,Python文件的前两行要这样写:
阅读全文
posted @
2020-05-14 16:29
仙人小麦
阅读(1397)
推荐(0)
测试组件 -ExcelHandler
摘要:"""处理Excel"""import xlrdfrom conf import settingsfrom utils.LogHandler import loggerclass ExcelOperate(object): def __init__(self, file_path, sheet_by
阅读全文
posted @
2020-05-14 14:32
仙人小麦
阅读(424)
推荐(0)
测试组件 AllureHandler
摘要:"""allure报告相关"""import osimport subprocessimport zipfileimport smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipa
阅读全文
posted @
2020-05-14 14:30
仙人小麦
阅读(143)
推荐(0)
测试组件 -RequestHandler
摘要:"""处理请求"""import reimport jsonimport requestsfrom jsonpath_rw import parsefrom urllib.parse import urlparsefrom conf import settingsfrom utils.LogHand
阅读全文
posted @
2020-05-14 14:28
仙人小麦
阅读(312)
推荐(0)
django离线脚本组件
摘要:import django import os,sys base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(base_dir) os.environ.setdefault("DJ
阅读全文
posted @
2020-05-08 15:24
仙人小麦
阅读(132)
推荐(0)
验证码组件:pillow
摘要:import random from PIL import Image,ImageDraw, ImageFont, ImageFilter def check_code(width=120, height=30, char_length=5, font_file='Monaco.ttf', font
阅读全文
posted @
2020-05-08 15:22
仙人小麦
阅读(170)
推荐(0)
加密组件
摘要:import uuid import hashlib from script import base from django.conf import settings def encrypt(info): hash_object = hashlib.md5(settings.SECRET_KEY.e
阅读全文
posted @
2020-05-08 15:20
仙人小麦
阅读(161)
推荐(0)
支付组件:支付宝
摘要:1.申请开通沙箱环境 https://openhome.alipay.com/platform/appDaily.htm?tab=info 注册成功之后会获取两个值: APPID,2016102400754054 支付宝网关 https://openapi.alipaydev.com/gateway
阅读全文
posted @
2020-05-08 14:52
仙人小麦
阅读(538)
推荐(0)
.gitignore组件
摘要:#pycharm.idea/__pycache__/*.py[cod]*$py.class#Django stuff:local_settings.py*.sqlite3# detabase migrations*/migrations/*.py!*/migrations/__init__.pyte
阅读全文
posted @
2020-05-08 13:37
仙人小麦
阅读(161)
推荐(0)
JS组件 + django hightcharts画折线图 饼图,柱状图
摘要:一,折线图 1.前端 <script src="{% static "plugin/highcharts/highcharts.js" %}"></script> 引用 <div class="panel panel-default"> <div class="panel-heading"> <i
阅读全文
posted @
2020-05-08 10:37
仙人小麦
阅读(791)
推荐(0)
JS组件 daterangepicker
摘要:1.引用 <div> <div class="input-group" style="width: 300px;"> <span class="input-group-addon">日期范围</span> <input id="rangePicker" type="text" class="form
阅读全文
posted @
2020-05-08 10:26
仙人小麦
阅读(933)
推荐(0)
JS组件 select2
摘要:1.引用 <script src="{% static "plugin/select2/js/i18n/zh-CN.js" %}"></script> <script src="{% static "plugin/select2/js/select2.min.js" %}"></script> 2.
阅读全文
posted @
2020-05-08 10:19
仙人小麦
阅读(587)
推荐(0)
JS组件bootsrap select
摘要:1.引入 <link rel="stylesheet" href="{% static "plugin/bootstrap-select/css/bootstrap-select.css" %}"> <script src="{% static "plugin/bootstrap-select/js
阅读全文
posted @
2020-05-08 10:13
仙人小麦
阅读(190)
推荐(0)
JS组件bootstrap-datepicker
摘要:1.引入 <link rel="stylesheet" href="{% static "plugin/bootstrap-datepicker/css/bootstrap-datepicker.min.css" %}"> <script src="{% static "plugin/bootstr
阅读全文
posted @
2020-05-08 10:02
仙人小麦
阅读(467)
推荐(0)
JS组件 markdown编辑器
摘要:1.前端html展示 <div id="content"> {{ field }} 这里必须是input type="text" 标签 </div> 2.JS 1.导入 <link rel="stylesheet" href="{% static "plugin/editor.md-master/c
阅读全文
posted @
2020-05-08 09:53
仙人小麦
阅读(1777)
推荐(0)
对象存储组件:腾讯对象存储
摘要:参考 腾讯官方文档 from qcloud_cos import CosConfig from qcloud_cos import CosS3Client from sts.sts import Sts from untitled import settings from qcloud_cos.co
阅读全文
posted @
2020-05-08 09:45
仙人小麦
阅读(255)
推荐(0)
短信验证码组件:腾讯云短信
摘要:参考:1.腾讯官方文档 2 .https://pythonav.com/wiki/detail/10/81/ 1.安装SDK pip install qcloudsms_py 2.基于SDK发送短信 # @Time : 2020/3/31 0031 下午 7:18 # @Author : Admin
阅读全文
posted @
2020-05-08 09:38
仙人小麦
阅读(419)
推荐(1)
inclusion_tag 组件
摘要:{% for item in data %} <li {% if item.class %} class="{{ item.class }}" {% endif %}> <a href="{{ item.url }}" > {{ item.name }} </a> </li> {% endfor %
阅读全文
posted @
2020-05-04 12:15
仙人小麦
阅读(120)
推荐(0)
自定制插件widget 组件
摘要:from django.forms.widgets import RadioSelect class ColorRadioSelect(RadioSelect): # input_type = 'radio' # template_name = 'django/forms/widgets/radio
阅读全文
posted @
2020-05-04 12:11
仙人小麦
阅读(195)
推荐(0)
BootStrapForm组件
摘要:class BootStrapForm(): bootstrap_exclude = [] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for name, field in self.fields.it
阅读全文
posted @
2020-05-04 12:07
仙人小麦
阅读(164)
推荐(0)
组合筛选组件
摘要:<div class="col-sm-3"> <div class="panel panel-default"> <div class="panel-heading"> <i class="fa fa-search" aria-hidden="true"></i>筛选 </div> <div cla
阅读全文
posted @
2020-05-03 18:27
仙人小麦
阅读(234)
推荐(0)