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);
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- more、less 和 most 的区别
- Python使用RethinkDB总结
- Python,Flex 2和Aptana[js开放工具]
- 国外开发者谈为何放弃PHP而改用Python
- 利用webqq协议使用python登录qq发消息源码参考
- python实现rest请求api示例
- linux cat more less显示文件的区别
- python 判断自定义对象类型
- 让python的Cookie.py模块支持冒号做key的方法
- Python 面向对象 成员的访问约束
- 新手该如何学python怎么学好python?
- Python linecache.getline()读取文件中特定一行的脚本
- 使用python检测手机QQ在线状态的脚本代码
- python getopt 参数处理小示例
- python 数据加密代码
- python实现倒计时的示例
- python使用PyV8执行javascript代码示例分享