利用http://tool.oschina.net/less 提供的接口,发送请求进行远程编译.
再将编译好的less,保存为同名后缀为css的文件中.
第一次使用python,代码也是拼拼凑凑的.需要加上线程进行异步请求,但是不会...
复制代码 代码如下:
import sublime, sublime_plugin
import urllib
import json
class exampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
file_name=self.view.file_name();
if file_name.find('.less') == -1:
print('only .less file can compile to css!!');
return;
file_object_from = open(file_name);
all_the_text = file_object_from.read();
url = "http://tool.oschina.net/action/less/less_compile";
data = all_the_text.encode(encoding='UTF8');
headers = {'User-Agent':'sublime_plugin'};
req = urllib.request.Request(url,data,headers);
response = urllib.request.urlopen(req);
the_page = response.read();
css=json.loads(the_page.decode("utf8"))['css'];
file_object_to = open(self.view.file_name().replace('.less', '.css'), 'w')
file_object_to.write(css);
file_object_from.close();
file_object_to.close();
print(css);
sublime3,less编译
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。