Python:cssmin压缩css代码

阅读 43

2022-02-13


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)

0 0 举报