This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def try_except_log(func): | |
""" | |
# 供参考 | |
装饰器: | |
1.抓取异常 | |
2.创建日志 | |
""" | |
def wrapper(*args, **kw): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
from uuid import uuid4 | |
uuidChars = ( | |
"a", "b", "c", "d", "e", "f", "g", | |
"h", "i", "j", "k", "l", "m", "n", | |
"o", "p", "q", "r", "s", "t", | |
"u", "v", "w", "x", "y", "z", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_months(dt, months): | |
""" | |
月加减 | |
:param dt: datetime 实例 | |
:param months: 加多少月 | |
:return: | |
""" | |
month = dt.month - 1 + months | |
year = dt.year + month / 12 | |
month = month % 12 + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time_cost(f): | |
""" | |
:param f: function | |
:return: 计算函数耗时多久 | |
""" | |
def _wrapper(*args, **kwargs): | |
now = time.time() | |
res = f(*args, **kwargs) | |
log_txt = u'函数 %s 耗时 %.2fs!' % (f.__name__, time.time() - now) | |
_logger.info(log_txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def date_range(begin_date, end_date): | |
""" | |
获取一个时间区间的list | |
""" | |
dates = [] | |
dt = datetime.datetime.strptime(begin_date, "%Y-%m-%d") | |
date = begin_date[:] | |
while date <= end_date: | |
dates.append(date) | |
dt = dt + datetime.timedelta(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min2millisec(t): | |
""" | |
将`03:36`转化成毫秒 | |
:param t: min string like '00:43' | |
:return: millisec int | |
""" | |
if not t: | |
return t | |
tim = t.split(":")[::-1] | |
depth = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard HEAD^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
False, True = True, False | |
if True: | |
print True, 1 | |
else: | |
print False, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
def _get_stars(date): | |
res = '' | |
star_key = { | |
1: ('摩羯座', '水瓶座'), | |
2: ('水瓶座', '双鱼座'), | |
3: ('双鱼座', '白羊座'), | |
4: ('白羊座', '金牛座'), | |
5: ('金牛座', '双子座'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 搜狗输入法--自定义短语配置文件 | |
; 自定义短语说明: | |
; 1、自定义短语支持多行、空格、指定位置。 | |
; 2、每条自定义短语最多支持30000个汉字,总共支持100000条自定义短语。 | |
; 3、自定义短语的格式如下: | |
; 单行的格式: | |
; 字符串+英文逗号+数字(指定排序位置)=短语 |
OlderNewer