0
点赞
收藏
分享

微信扫一扫

Python:cssmin压缩css代码

猎书客er 2022-02-13 阅读 43


PyPI: ​​​https://pypi.org/project/cssmin/​​​

Github: ​​​https://github.com/zacharyvoase/cssmin​​​

安装

pip install cssmin

使用示例

main.css

.box{
background-color: red;
}

1、命令行中使用

$ cat main.css | cssmin

.box{background-color:red}

2、代码中使用

# -*- coding: utf-8 -*-
import cssmin

with open('main.css') as f:
output = cssmin.cssmin(f.read())
print(output)

# .box{background-color:red}



举报

相关推荐

0 条评论