This file contains hidden or 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
import json | |
json.dumps(response, ensure_ascii=False).encoding('utf-8') |
This file contains hidden or 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
datetime.datetime.fromtimestamp( | |
int("1284101485") | |
).strftime('%Y-%m-%d %H:%M:%S') |
This file contains hidden or 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
import time | |
import functools | |
def clock(func): | |
@functools.wraps(func) # relace with orig func's __name__ and __doc__ | |
def clocked(*args, **kwargs): | |
t0 = time.time() | |
result = func(*args, **kwargs) | |
elapsed = time.time() - t0 | |
name = func.__name__ |
This file contains hidden or 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
from functools import singledispatch | |
from collections import abc | |
import numbers | |
import html | |
@singledispatch | |
def htmlize(obj): | |
content = html.escape(repr(obj)) | |
return '<pre>{}</pre>'.format(content) |