分类 "Python" 下的文章

问题: ubuntu下如何安装python3.9

解决: 使用安装包安装

方法:

sudo apt install -y wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0b4.tgz
tar -zxvf Python-3.9.0b4.tgz

阅读全文

问题:python程序如何加密?

解决:

方法:

加密add.py文件
from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules = cythonize(["add.py"]))

阅读全文

问题:如何批量下载文件并打包成压缩包进行下载?

解决:使用python内置模块zipfile

方法:

from zipfile import ZipFile
class DownloadHanlder(BaseHandler):
    zipfile_path = os.path.realpath(
        os.path.join(os.path.dirname(__file__),
                     "../../static/download/Data.zip"))
    newzip = ZipFile(zipfile_path, "w")

阅读全文