文章目录
- 1.安装依赖
- 2.目录结构
- 3.代码
- 4.执行结果
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)