from django.http import HttpResponse
from .utils import queryset_to_workbook
def download_workbook(request):
queryset = User.objects.all()
columns = (
'first_name',
'last_name',
'email',
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
package http_api | |
import ( | |
"fmt" | |
"strings" | |
) | |
type node struct { | |
path string // 路由路径 | |
part string // 路由中由'/'分隔的部分, 比如路由/hello/:name,那么part就是hello和: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
#!/usr/bin/python | |
""" | |
面试题 | |
Q:有一个大文件日志,日志内容包含 访问时间 和 访问 IP,问如何统计每分钟访问次数超过 100 次的 IP ? | |
访问日志文件内的数据都是根据时间有序排列的。所以只要逐行处理,把秒去掉,然后利用字典统计每分钟内的IP访问次数。 | |
到下一分钟了就把字典清空,重新统计就可以了。 |
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
#!/usr/bin/env python | |
# -*-coding: utf-8-*- | |
import datetime | |
import xlwt | |
workbook = xlwt.Workbook() | |
worksheet = workbook.add_sheet('My Sheet') | |
# style = xlwt.XFStyle() |
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
class OpsIPInfoAdmin(admin.ModelAdmin): | |
def get_readonly_fields(self, request, obj=None): | |
# make all fields readonly | |
readonly_fields = list( | |
set([field.name for field in self.opts.local_fields] + | |
[field.name for field in self.opts.local_many_to_many]))) | |
if 'is_submitted' in readonly_fields: | |
readonly_fields.remove('is_submitted') |