python实现sublime3的less编译插件示例
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);
- Python动态类型的学习---引用的理解
- 垃圾邮件过滤器 python简单实现
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- more、less 和 most 的区别
- Python使用RethinkDB总结
- Python,Flex 2和Aptana[js开放工具]
- 国外开发者谈为何放弃PHP而改用Python
- 利用webqq协议使用python登录qq发消息源码参考