摘要:flask flask-wtf flask-script flask-SQLAlchemy flask-RESTFul flask-Blueprint flask-mysqldb
阅读全文
摘要:import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s %(funcName)s():%(lineno)d %(levelname)s %(message)s', datefmt
阅读全文
摘要:有时候,为了需求,需要统计两个 list 之间的交集,并集,差集。查询了一些资料,现在总结在下面:1. 获取两个list 的交集#方法一:a=[2,3,4,5]b=[2,5,8]tmp=[valforvalinaifvalinb]printtmp#[2,5]#方法二printlist(set(a)....
阅读全文
摘要:filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回:>>> def f(x): return x % 2 != 0 an...
阅读全文
摘要:#!/usr/bin/env python2#-*- coding: utf-8 -*-def retry(attempt): def decorator(func): def wrapper(*args, **kw): print ...
阅读全文
摘要:引子字典,形如 dic = {'a':1 , 'b':2 , 'c': 3},字典中的元素没有顺序,所以dic[0]是有语法错误的。并且不可以有重复的键值,所以dic.add['c'] = 4后,字典变成 {'a':1 , 'b':2 , 'c': 4}.待解决问题如何根据需要可以根据“键”或“键值...
阅读全文
摘要:def intToList(ret): list = [] for i in range(1, 8): list.append(a & 2**i and 1) return list#python2.6以后内置函数#10进制转为2进制>>>bin(10)'0b1010...
阅读全文
摘要:python -m SimpleHTTPServer 8080
阅读全文
摘要:test_\@.pyclass myDecorator(object): def __init__(self, f): print "inside myDecorator.__init__()" self.f = f def __call__(...
阅读全文
摘要:test_\@.py#!/usr/bin/env python2#-*- coding: utf-8 -*-def args(*args, **kwargs): def _decorator(func): print "befor ", func.__dict__ ...
阅读全文
摘要:re.match re.match 尝试从字符串的开始匹配一个模式,如:下面的例子匹配第一个单词。[python]view plaincopyimportretext="JGoodisahandsomeboy,heiscool,clever,andsoon..."m=re.match(r"(/w+...
阅读全文
摘要:原文http://webpy.org/formimport webfrom web import formrender = web.template.render('templates/')urls = ('/', 'index')app = web.application(urls, global...
阅读全文
摘要:#!/usr/bin/env python2#-*- coding: utf-8 -*-import urlliburl = "http://www.baidu.com"def getHtml(url): page = urllib.urlopen(url) html = page.re...
阅读全文
摘要:函数原型:find(str,pos_start,pos_end)解释:str:被查找“字串”pos_start:查找的首字母位置(从0开始计数。默认:0)pos_end: 查找的末尾位置(默认-1)返回值:如果查到:返回查找的第一个出现的位置。否则,返回-1。举例论证: 1.st...
阅读全文