Python:cssmin压缩css代码

安装

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}