Python
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 VS Python3
· ☕ 1 分钟
1. Python 2 和 3 区别 特征\版本 Python 2 Python 3 print 函数化 print“abc” print(“abc”) 统一类 旧式类和新式类 只有新式类 浮点运算 1/2=0 1/2=0.5 字符串格式化 %,Format Format,% xrange 替代 range xrange range long 重命名为 int Long,int Int 包导入 相对导入 绝对导入 源文件编码 Ascii utf8 Python 官方强烈建议直接学习 Python 3,因为 Python 2 只维护到 2020 年。但是现

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 图形用户界面程序,

如何使用 devpi 搭建 PyPI Server
· ☕ 3 分钟
使用 pip 命令安装 Python 包时,默认去 https://pypi.python.org/simple/ 源查找相应的包,下载并安装。但是在内网环境,或者需要发布一些私有包提供给指定用户时,就需要搭建自己的 PyPI Server。本篇主要记录使用 devpi 工具搭建 PyPI Server 源的过程,以及记录一些常用命令。 1. PyPI Server 比较 PyPI Server PyPI 代理镜像 本地缓存