博文
Django 开发中常用命令
· ☕ 1 分钟
创建 Django 工程 1 django-admin startproject your_project_name 创建应用 1 2 3 django-admin.py startapp your_app_name # 或者 python manage.py startapp your_app_name python manage.py 和 django-admin 的功能基本一样。不同的是 python manage.py 还设置了 DJANGO_SETTINGS_MODULE 环境变量、将项目的路径加入了 sys.path 中。建议除了创建项目使用 django-admin,其他情况使用 python manage.py。 初始化数据 1 python manage.py migrate 创建缓存表

Python2 源码学习之字典和列表实现
· ☕ 6 分钟
1. 为什么字典比列表查询快 首先,请看下面这段代码 1 2 3 4 5 6 7 8 9 10 11 12 13 from time import time t = time() data = [chr(i) for i in range(97, 123)] # data = dict.fromkeys(data,True) print data for i in range(9999999): after_filter = [] for find in ['aa', 'b', 'cc', 'd', 'ee']: if find not in data: after_filter.append(find) print after_filter print time() - t 直接运行: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] ['aa', 'cc', 'ee'] 24.5699999332 去

Python2 源码学习之 Windows 编译
· ☕ 3 分钟
1. 编译器准备 准备 Python 源码 在 Python 的官网,下载需要进行编译的 Python 版本源代码。这里选择的是 Python 2 的最新版本 Python-2.7.14.tar.xz,点击前往。 准备编译器 在 Windows 上,Python 2.7 的源代码内置的项目工程,支持 Visual Studio 2008、2010 打开。当然,V

Python2 源码学习之 pyc
· ☕ 5 分钟
文中以 Python 2.7.8 版本源码为例。 1. Python 中常见的文件格式 py 文件 Python 源代码文件,可以使用文本编辑器进行修改。 pyc 文件 Python 源代码编译后,生成的字节码文件。 pyw 文件 pyc 文件执行时,会出现 console 窗口;pyw 文件执行时,不会出现。pyw 文件主要是用来运行纯 GUI 图形用户界面程序,

编写可阅读代码的艺术读书笔记
· ☕ 1 分钟
1. 关于名字 选择专业的词 避免泛泛的名字 用具体的名字代替抽象的名字 使用前缀或后缀给名字附带更多的信息 决定名字的长度 利用名字的格式来表达含义 2. 把信息装到名字里 通常来讲,加上像 is、has、can 或 should 这样的词,可以把布尔值变得更明确。 get 开头的方法,