摘要: datetime object转化为timestamp 1 import datetime 2 now = datetime.datetime.now() 3 now_timestamp = time.mktime(now.timetuple()) timestamp 转化为 datetime ob 阅读全文
posted @ 2019-04-24 16:11 琵琶真的行 阅读(286) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "math/rand" "time" ) // 数据生产者 func producer(header string, channel chan<- string) { // 无限循环, 不停地生产数据 for { // 将随机数和字符串格式化为 阅读全文
posted @ 2019-04-19 17:50 琵琶真的行 阅读(1086) 评论(0) 推荐(0) 编辑
摘要: 生产者-消费者模式 阅读全文
posted @ 2019-04-18 16:13 琵琶真的行 阅读(619) 评论(0) 推荐(0) 编辑
摘要: #settings.py DATABASES = { 'default': { 'OPTIONS': { "init_command":"SET foreign_key_checks = 0;", #取消foreignkey的严格检查 "charset": "utf8mb4", #编码集修改,utf8mb4为utf8的扩展... 阅读全文
posted @ 2019-04-16 16:56 琵琶真的行 阅读(388) 评论(0) 推荐(0) 编辑
摘要: django时区默认使用UTC,中国人使用CST东八区。 settings.py改为上海时区 系统时区保持一致: 阅读全文
posted @ 2019-04-16 15:29 琵琶真的行 阅读(419) 评论(0) 推荐(0) 编辑
摘要: 如何使程序在特定时间只执行一次,我查了一下。 celery可以,时间以秒计。 不过,我们存在以天、星期、甚至月的倒计时,感觉celery还是不满足需求。 最后找到了apscheduler。 from django.utils import timezone from apscheduler.sche 阅读全文
posted @ 2019-04-16 10:53 琵琶真的行 阅读(3265) 评论(0) 推荐(0) 编辑
摘要: 假如生活欺骗了你不要悲伤 不要心急忧郁的日子里须要镇静相信吧 快乐的日子将会来临心儿永远向往着未来现在却常是忧郁一切都是瞬息一切都将会过去而那过去了的就会成为亲切的回忆 阅读全文
posted @ 2019-04-13 18:32 琵琶真的行 阅读(160) 评论(0) 推荐(0) 编辑
摘要: #views.py from django.shortcuts import render_to_response, RequestContext from django.views.decorators.csrf import csrf_protect @csrf_protect def index(request): if request.method == "GET... 阅读全文
posted @ 2019-04-13 18:30 琵琶真的行 阅读(650) 评论(0) 推荐(0) 编辑
摘要: #settings.py import os from mongoengine import * BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) DEBUG = False ALLOWED_HOSTS = ['*'] # Database # https://docs.djangoproject... 阅读全文
posted @ 2019-04-13 18:21 琵琶真的行 阅读(1868) 评论(0) 推荐(0) 编辑
摘要: LOG_LEVEL = 'DEBUG' LOGGING = { 'version' : 1, 'disable_existing_loggers' : True, 'formatters' : { 'standard' : { 'format' : '%(asctime)s [%(threadNam 阅读全文
posted @ 2019-04-13 18:20 琵琶真的行 阅读(211) 评论(0) 推荐(0) 编辑