加载中
python 作用域

a.py from b import B from c import fc bb = B('123') bb.fc = fc bb.fc() # 123 b.py class B(object): def init(self, xx): self.xx = xx c.py xx = '123' def fc(): print(xx)......

03/14 10:42
2
python pylint

尽量按照pylint的意见,修改自己的代码,提升编码的品味 pylint: static code analysis tool pip install pylint pylint xx.py Environment variables: The following environment variables...

Python operator

Operation Syntax Function Addition a + b add(a, b) Concatenation seq1 + seq2 concat(seq1, seq2) Containment Test obj in seq contains(seq, obj) Division a / b truediv(a, b) Divis...

03/08 14:03
0
Python 装饰器

函数装饰器 def des(func): def wrap(a, b): print('in des') res = func(a,b) if res > 5: return 'big' else: return 'small' return wrap ......

03/08 10:52
1
Python itertools

Infinite iterators: Iterator Arguments Results Example count() start, [step] start, start+step, start+2*step, … count(10) --> 10 11 12 13 14... cycle() p p0, p1, … plast, p0,...

Python Flask 路由

正则匹配 demo from flask import Flask, send_file from werkzeug.routing import BaseConverter class RegexConverter(BaseConverter): def init(self, url_map, *items): super(RegexConv...

解释 defaultdict

lambda to be continued

02/18 13:56
0
Python map, filter, reduce

map def do(a, b): print(a) print(b) print('----------') list(map(do, [1,3],[2,4])) 1 2 #---------- 3 4 #---------- filter def positive(x): if x: return x list(fil......

02/15 10:58
1
Python dis

Disassembler for Python bytecode def myfunc(alist): return len(alist) import dis dis.dis(myfunc) 2 0 LOAD_GLOBAL 0 (len) 2 LOAD_FAST 0 (......

02/13 22:03
0
有向图广度优先搜索 (BFS for a Graph)

from collections import defaultdict class Graph: def init(self): self.graph = defaultdict(list) def addEdge(self, u, v): self.graph[u].append(v) def BFS(self, s):......

02/12 17:45
0
Python collections

容器类型 类型 描述 namedtuple factory function for creating tuple subclasses with named fields deque list-like container with fast appends and pops on either end ChainMap dict-l...

无向图

adjacency list 实现 class AdjNode: def init(self, data): self.vertex = data self.next = None class Graph: def init(self, vertices): self.V = vertices ......

def
02/12 15:52
0
块设备IO情况查询

Block layer statistics in /sys/block/<dev>/stat Name units description read I/Os requests number of read I/Os processed read ......

02/06 23:26
1
SQL笔记

SQL 是用于访问和处理数据库的标准的计算机语言 SQL 指结构化查询语言,全称是 Structured Query Language SQL 是一种 ANSI(American National Standards Institute 美国国家标准化组织)标...

02/06 22:50
0
旧版 PyPI 日更记录

sqlite3 def init_db(): conn = sqlite3.connect(PYPI_DB) conn.execute('''CREATE TABLE IF NOT EXISTS PYPI ( ID INTEGER PRIMARY KEY AUTOINCREMENT, ......

Django 上传文件

settings.py STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') urls.py from django.co...

02/05 17:18
0
Python 常用时间处理方法

time datetime 今天 today = datetime.date.today() 昨天 yesterday = today - datetime.timedelta(days=1) 上个月 last_month = today.month - 1 if today.month - 1 else 12 当前时间戳 ti...

02/04 14:52
14
Python调试方法

print print('here') 可以发现某段逻辑是否执行 打印出变量的内容 assert assert false, 'blabla' 如果条件不成立,则打印出 'blabla' 并抛出AssertionError异常 debugger 可以通过 pdb、IDE...

02/04 13:55
9
git

push to git node # run this cmd at git node $ git config receive.denyCurrentBranch ignore git clone from ssh git clone ssh://<user>@<ip>:<port>/~/path/xx.git git clone including...

Git
01/29 22:19
0
python 操作 leveldb

import plyvel db = plyvel.DB('./repo', create_if_missing=True) repo/ |-- 000018.ldb |-- 000020.ldb |-- 000021.log |-- CURRENT |-- LOCK |-- LOG |-- LOG.old |-- MANIFEST-000019 .....

没有更多内容

加载失败,请刷新页面

返回顶部
顶部