2020年4月2日

python策略模式

摘要: from abc import ABC,abstractmethod from collections import namedtuple ##############商品类############## class Item: def __init__(self,name,price,num): s 阅读全文

posted @ 2020-04-02 20:48 不要挡着我晒太阳 阅读(190) 评论(0) 推荐(0) 编辑

CAP原则(CAP定理)、BASE理论

摘要: 一、CAP原则 CAP原则又称CAP定理,指的是在一个分布式系统中, Consistency(一致性)、 Availability(可用性)、Partition tolerance(分区容错性),三者不可得兼。 CAP原则是NOSQL数据库的基石。 分布式系统的CAP理论:理论首先把分布式系统中的三 阅读全文

posted @ 2020-04-02 18:08 不要挡着我晒太阳 阅读(223) 评论(0) 推荐(0) 编辑

简单了解电商项目中的一些技术

摘要: 秒杀:秒杀是通常意味着要在很短的时间处理极高的并发,系统在短时间需要承受平时百倍以上的流量,因此秒杀架构是一个比较复杂的问题,其核心思路是流量控制和性能优化,需要从前端(通过JavaScript实现倒计时、避免重复提交和限制频繁刷新)到后台各个环节的配合。流量控制主要是限制只有少部分流量进入服务后端 阅读全文

posted @ 2020-04-02 18:06 不要挡着我晒太阳 阅读(411) 评论(0) 推荐(0) 编辑

Python自动群发邮件

摘要: import smtplib from email import (header) from email.mime import (text, application, multipart) import time def sender_mail(): smt_p = smtplib.SMTP() 阅读全文

posted @ 2020-04-02 16:59 不要挡着我晒太阳 阅读(342) 评论(0) 推荐(0) 编辑

python chardet 模块

摘要: 兴高采烈地,从网页上抓取一段 content 但是,一 print 就不那么兴高采烈了,结果看到一串这个: b'\xc8\xcb\xc9\xfa\xbf\xe0\xb6\xcc\xa3\xac\xce\xd2\xd3\xc3Python' 这是啥? 又 x 又 c 的! 再一看,哦,原来是十六进制字 阅读全文

posted @ 2020-04-02 13:43 不要挡着我晒太阳 阅读(563) 评论(0) 推荐(0) 编辑

python pretty-errors模块

摘要: 一行代码优化输出的异常信息 pip install pretty-errors 写一个函数测试: def divided_zero(): for i in range(10, -1, -1): print(10/i) divided_zero() 在没有import这个pretty-errors前, 阅读全文

posted @ 2020-04-02 13:07 不要挡着我晒太阳 阅读(970) 评论(0) 推荐(1) 编辑

认识执行时机

摘要: array = [1, 3, 5] g = (x for x in array if array.count(x) > 0) g为生成器,list(g)后返回[1,3,5],因为每个元素肯定至少都出现一次。所以这个结果这不足为奇。但是,请看下例: array = [1, 3, 5] g = (x f 阅读全文

posted @ 2020-04-02 12:59 不要挡着我晒太阳 阅读(192) 评论(0) 推荐(0) 编辑

python对象销毁顺序

摘要: 创建一个类SE: class SE(object): def __init__(self): print('init') def __del__(self): print('del') 创建两个SE实例,使用is判断: In [63]: SE() is SE() init init del del 阅读全文

posted @ 2020-04-02 12:37 不要挡着我晒太阳 阅读(424) 评论(0) 推荐(0) 编辑

导航