Python中,py文件转pyd文件

一,来源:

  1. 开发过程中经常遇到需要加密或加快运行速度的需求,此时可以将py文件转为pyd文件,可以加快运行速度

二,步骤

  1. 创建setup.py文件,编辑以下内容
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# here put the import lib
from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules=cythonize(["要转换的py文件名.py"]))
  1. 运行以下命令,即可生成pyd文件
python setup.py build_ext --inplace

猜你喜欢

转载自blog.csdn.net/zhuan_long/article/details/133386485