我试图用python包编译sass,我是不是做错了什么?似乎我使用的是正确的sass语法,但是仍然会出现错误,它希望在每一行的末尾都有分号,非常奇怪:
> pip install libsass
> Successfully installed libsass-0.13.3
...
>>> sass.compile(string='$a: 1\n$b: 2')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\anaconda\lib\site-packages\sass.py", line 640, in compile
raise CompileError(v)
sass.CompileError: Error: Invalid CSS after "$b": expected 1 selector or at-rule, was ": 2"
on line 2 of stdin
>> $b: 2
^发布于 2017-11-08 19:05:31
据我所知,saas中每一行后面都需要分号。
看一看文档
因此,在您的示例中,应该是:
sass.compile(string='$a: 1;\n$b: 2;')UPDATE:如果你真的想看到编译器的一些输出,你需要使用你设置的SASS属性。
举个例子:
print sass.compile(string='$primary_color: blue;\n a { b { color: $primary_color; } }')将打印出来:
a b {
color: blue; }查看如何在生成的CSS中将变量$primary_color编译为蓝色。
https://stackoverflow.com/questions/47186997
复制相似问题