- 博客(909)
- 收藏
- 关注
原创 sqlite-python3
import sqlite3 import sysimport osdropbox = os.getenv("dropbox")config = os.getenv("my_config")dbfile = ("Databases\jarvis.db")listfile = ("sqlite_master_table.lst")master_db = os.path.join(dropbox, dbfile)config_file = os.path.
2021-12-01 20:59:57
1067
原创 链表队列 算法
from typing import Optionalclass Node: def __init__(self, data: str, next=None): self.data = data self._next = nextclass LinkedQueue: def __init__(self): self._head: Optional[Node] = None self._tail: Optional.
2021-10-10 22:34:30
311
原创 链表栈算法
from typing import Optionalclass Node: def __init__(self, data: int, next=None): self._data = data self._next = next class LinkedStack: """A stack based upon singly-linked list. """ def __init__(self): s
2021-10-10 22:27:36
310
原创 2021-10-10链表题
""" 1) Reverse singly-linked list 2) Detect cycle in a list 3) Merge two sorted lists 4) Remove nth node from the end 5) Find middle node"""from typing import Optionalclass Node: def __init__(self, data: int, next=None):
2021-10-10 14:44:07
108
原创 2021-10-10数组
数组的实现连续空间## 1) Insertion, deletion and random access of array# 2) Assumes int for element typeclass MyArray: """A simple wrapper around List. You cannot have -1 in the array. """ def __init__(self, capacity: int): self._dat
2021-10-10 14:01:38
100
翻译 简单的分布式
from multiprocessing.managers import BaseManagerhost = '127.0.0.1'port = 9030authkey = 'secret'shared_list = []class RemoteManager(BaseManager): passRemoteManager.register('get_list', callable=lambda: shared_list)mgr = RemoteManager(addres
2021-09-08 18:08:22
90
原创 装饰器python3 2021
# The decorator to make it bolddef makebold(fn): # The new function the decorator returns def wrapper(): # Insertion of some code before and after return "<b>" + fn() + "</b>" return wrapper# The decorator to make
2021-08-26 16:43:17
83
原创 2021-08-26 装饰器
from functools import wrapsdef makebold(fn): @wraps(fn) def wrapper(*args, **kwargs): return "<b>" + fn(*args, **kwargs) + "</b>" return wrapperdef makeitalic(fn): @wraps(fn) def wrapper(*args, **kwargs):
2021-08-26 16:32:06
82
原创 2021-08-25 py协程
# 代码片段1#一个协程执行流程被打断的最主要的原因就是在协程内部调用了另一个协程函数import asyncioimport asyncio.coroutinesdef _set_result_unless_cancelled(fut, result): if fut.cancelled(): return print("this is a rewrited sleep callback function") fut.set_result(result)
2021-08-25 16:10:27
116
原创 排行榜redis
import ujsonimport functoolsclass RanklistBase(dict): def __init__(self, name, redis_handler, ex=30): self.name = name self.redis_handler = redis_handler self.ex = ex self.ranklist = [] self.plugin_functions
2021-08-25 10:49:28
184
翻译 2021-08-24选择比努力更加重要
第一个故事,微软的测试团队改革。陆奇是一个程序员从技术做起,进而翻身的典范。最初他入职雅虎的时候只是一个普通的工程师,十多年后 ,他以执行副总裁的身份,不但牵头打造了 Bing 搜索,还完成了几项意义深远的改革,其中一项,就是合并开发和测试这两个原本独立的部门,大幅裁剪专职测试人员,让工程师做更多的事。这样一来,有一些擅长使用内部测试工具进行测试的工程师,就慢慢丢掉工作了,原因很简单,他们更多的只是熟练工,而缺乏技术上的竞争力。听起来,这似乎是微软内部组织架构变动和工具、技术栈封闭的锅。其实,合并开发和测试
2021-08-24 12:51:11
139
翻译 冒泡排序以及其改进
def bubble_sort(alist): count = 0 for j in range(0,len(alist) - 1):#整个数列排序循环 for i in range(0,len(alist) - 1 - j): # 元素从头走到尾,走完一次,排好一个数 if alist[i] > alist[i + 1]: #因为要和下一个数相比,所以i只需要走到len(alist) -.
2021-08-19 19:34:13
102
原创 学习java
public class User { private final static User user = new User(); private User() { } public static User getInstance(){ return user; }} 饿汉单例模式
2021-06-17 23:34:55
90
原创 PyQt5代理
from PyQt4.QtCore import (QDate, QSize, QString, QVariant, Qt, SIGNAL)from PyQt4.QtGui import (QApplication, QColor, QDateEdit, QLineEdit, QSpinBox, QStyle, QStyledItemDelegate, QTextDocument)import richtextlineeditclass GenericDelegate(QStyle
2021-05-20 22:20:14
376
翻译 可拖动pyqt
class Tree(QtWidgets.QTreeWidget): # ... def dropEvent(self, event): if event.source() == self: event.setDropAction(QtCore.Qt.MoveAction) super().dropEvent(event) elif isinstance(event.source(), QtWidgets.QL
2021-05-13 23:44:17
124
翻译 qtreewidget
# -*- coding: utf-8 -*-"""这是一个关于TIM模拟(QTreeWidget)的例子!"""import sysimport codecsimport randomfrom PyQt5.QtCore import Qt, QSize, pyqtSlot, QVariantfrom PyQt5.QtGui import QIcon, QFont, QBrush, QStandardItemModelfrom PyQt5.QtWidgets import QWid
2021-05-12 00:03:18
199
翻译 pyqt combobox
import sysfrom PyQt5.QtWidgets import QApplication, QComboBox, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QMessageBoxfrom PyQt5.QtGui import QPixmap, QIconclass ExComboBox(QWidget): ''' 下拉框简单举例 ''' def __init__(self): '''
2021-05-11 23:18:50
262
翻译 java代码分层
开放接口层:可直接封装Service接口暴露成RPC接口;通过Web封装成http接口;网关控制层等。终端显示层:各个端的模板渲染并执行显示层。当前主要是velocity渲染,JS渲染,JSP渲染,移动端展示层等。Web层:主要是对访问控制进行转发,各类基本参数校验,或者不复用的业务简单处理等。Service 层:相对具体的业务逻辑服务层。Manager 层:通用业务处理层,它有如下特征:对第三方平台封装的层,预处理返回结果及转化异常信息对Service层通用能力的下沉,如缓存方案、中间件通用处
2021-05-09 14:58:08
498
翻译 java mvc 分层
在阿里巴巴编码规约中列举了下面几个领域模型规约:DO(Data Object):与数据库表结构一一对应,通过DAO层向上传输数据源对象。DTO(Data Transfer Object):数据传输对象,Service或Manager向外传输的对象。BO(Business Object):业务对象。由Service层输出的封装业务逻辑的对象。AO(Application Object):应用对象。在Web层与Service层之间抽象的复用对象模型,极为贴近展示层,复用度不高。VO(View Obje
2021-05-07 22:57:51
100
翻译 listview
from PyQt5.QtWidgets import QApplication, QWidget , QVBoxLayout , QListView, QMessageBoxfrom PyQt5.QtCore import QStringListModel import sys class ListViewDemo(QWidget): def __init__(self, parent=None): super(ListViewDemo, self).__init__(parent) s
2021-05-05 10:25:25
88
翻译 pyside6 treewidget
def addTopLevelItem (item)def addTopLevelItems (items)def clear ()def closePersistentEditor (item[, column=0])def collapseItem (item)def columnCount ()def currentColumn ()def currentItem ()def currentItemChanged (current, previous)def edi
2021-05-05 10:02:18
378
翻译 Python SQLAlchemy demo
"""Create 操作"""from faker import Factoryfrom sqlalchemy import create_engine, Column, Integer, Stringfrom sqlalchemy.ext.declarative import declarative_basefrom sqlalchemy.orm import sessionmakerfaker = Factory.create()engine = create_engine('m.
2021-05-04 18:24:51
320
原创 py属性小结对比
class Timer: def __init__(self, value = 0.0): # 1. 将变量加"_",标志这是私有成员 self._time = value self._unit = 's' def get_time(self): return str(self._time) + ' ' + self._unit def set_time(self, value): if(value < 0): raise V
2021-04-24 22:43:30
82
原创 赏金猎人
#include<stdio.h>#include<iostream>#include<queue>#include<vector>// #include<bits/stdc++.h>using namespace std;struct people{ int attack,money,id,res;};people a[100010];bool cmp(people a,people b){ return.
2021-04-15 23:29:18
179
翻译 leetcode-53-cpp
class Solution {public: struct Status { int lSum, rSum, mSum, iSum; }; Status pushUp(Status l, Status r) { int iSum = l.iSum + r.iSum; int lSum = max(l.lSum, l.iSum + r.lSum); int rSum = max(r.rSum, r.iSum + l.
2021-04-09 09:41:57
103
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人