1.mytest.py 需要加密的内容

#coding:utf-8
import datetime

class Today():
    def get_time(self):
        print(datetime.datetime.now())

    def say(self):
        print("hello word!")

today = Today()
today.say()
today.get_time()

2.执行setup.py 也就是加密脚本

from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules=cythonize(["mytest.py"]), script_args=['build_ext', '--inplace'])

3.用so_test.py调用生成的.so文件 

from mytest import Today

t = Today()
print('=====================')
t.say()
t.get_time()

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐