Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Bootstrap Template</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link href="css/bootstrap-responsive.min.css" rel="stylesheet" media="screen"/> | |
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen"/> | |
</head> | |
<body> | |
<h1>Hello, world!</h1> |
.clearfix:after { | |
content: "."; | |
display: block; | |
clear: both; | |
visibility: hidden; | |
line-height: 0; | |
height: 0; | |
} | |
.clearfix { |
import doctest | |
import inspect | |
def gen_key_factory(key_pattern, arg_names, defaults): | |
""" | |
产生gen_key 函数的工厂 | |
洪教授python在web 2.0 网站中的应用演讲中 gen_key_factory函数的自己实现版本 | |
""" | |
def gen_key(*a, **kw): | |
values = list(a) |
def damerau_levenshtein_distance(source, target): | |
if not source and not target: | |
return 0 | |
elif not source: | |
return len(target) | |
elif not target: | |
return len(source) |
##Part 1 | |
#iteration | |
class countdown_iter(object): | |
def __init__(self, start): | |
self.count = start | |
def __iter__(self): | |
return self | |
def next(self): | |
if self.count <= 0: | |
raise StopIteration |
#include "stdafx.h" | |
using namespace std; | |
class C180 | |
{ | |
public: | |
C180() { | |
foo(); | |
this->foo(); |
import time | |
import sys | |
# reload(sys) | |
# sys.setdefaultencoding('utf8') | |
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None): | |
def deco_retry(f): | |
def f_retry(*args, **kwargs): | |
mtries, mdelay = tries, delay |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# --- coding:utf-8 --- | |
import strategy | |
import bjoern | |
from urlparse import parse_qsl | |
strategys = [strategy.strategy_highfreq, strategy.strategy_repetition] | |
actions = ['answer', 'comment', 'question'] | |
limit_time = 10 | |
datas = [] |
import os | |
import smtplib | |
import argparse | |
import re | |
import mimetypes | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email.MIMEText import MIMEText | |
from email.Utils import formatdate, COMMASPACE | |
from email import Encoders |