python实现生成验证码的逻辑

python实现生成验证码的逻辑

 假设我们有一个fonts的文件夹,里面有1.ttf,2.ttf,3.ttf三个字体文件具体代码实现代码codes.py:# coding:utf8from PIL import ImageDraw, ImageColor, ImageFile, ImageFont, ImageFilter, Imageimport randomimport os...
@classmethod与@staticmethod以及属性函数@property

@classmethod与@staticmethod以及属性函数@property

之前是一知半解,现在懂了,记录一下@classmethod举例class Date(object): def __init__(self,day=0,month=0,year=0) self.day = day self.month = month self.year = year @classmethod ...
符合语言习惯的Python编程技巧

符合语言习惯的Python编程技巧

Python最大的优点之一就是语法简洁,好的代码就像伪代码一样,干净、整洁、一目了然。要写出 Pythonic(优雅的、地道的、整洁的)代码,需要多看多学大牛们写的代码,github 上有很多非常优秀的源代码值得阅读,比如:reque...
Python的flask:models.py来创建mysql数据库

Python的flask:models.py来创建mysql数据库

Python 3.6用到的包flask下有一个叫flask_sqlalchemy的数据库框架,没有安装的可以使用下面的来安装$ pip install -i https://pypi.douban.com/simple/ flask-sqlalchemyflask就不多说了$ pip install -i https://pypi.doub...
Python使用virtualenvwrapper创建虚拟环境

Python使用virtualenvwrapper创建虚拟环境

为了不影响本地的大环境或者同时安装python2以及python3之后的方便切换,使用python的虚拟环境大多数用virtualenv来做,我用virtualenvwrapper来做,方便管理 Windows环境下假设python3在path下,python2未添加安装pip inst...
flask的Blueprint,前后台蓝图注册

flask的Blueprint,前后台蓝图注册

文件结构创建一个shizhan文件夹,根据flask的文件结构,在shizhan里面创建app文件夹,其他如下的结构├── app│   ├── __init__.py│   ├── admin│   │   ├── __init__.py│   │   └── views.py│   ├── home│   │   ├── __init_...
python利用smtp来发送邮件(带附件)

python利用smtp来发送邮件(带附件)

运行环境:python2.7,python3.x的话,把代码中的中文的字符前的u去掉就好,这是2与3基本的区别# -*- coding: utf-8 -*-import smtplibimport email.MIMEMultipart  # import MIMEMultipartimport email.MIMEText  # import...