Pyhton压缩JS代码


1.安装依赖

pip install jsmin

2.目录结构

在这里插入图片描述


3.代码

import jsmin


def run(src_path, tgt_path):
    with open(src_path, "r", encoding='utf-8') as input_file:
        with open(tgt_path, "w", encoding='utf-8') as output_file:
            output_file.write(jsmin.jsmin(input_file.read()))


if __name__ == '__main__':

    # 压缩哪个js
    src_path = "./src/ExLibris列表页.js"

    # 压缩后放哪
    tgt_path = "./tgt/ExLibris列表页.js"

    # 执行
    run(src_path, tgt_path)


4.执行结果

在这里插入图片描述


猜你喜欢

转载自blog.csdn.net/weixin_43721000/article/details/132970472
今日推荐