• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现sublime3的less编译插件示例

python实现sublime3的less编译插件示例

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了sublime python,sublime python插件,sublime text python,sublime python配置,sublime 运行python等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

利用http://tool.oschina.net/less 提供的接口,发送请求进行远程编译.
再将编译好的less,保存为同名后缀为css的文件中.
第一次使用python,代码也是拼拼凑凑的.需要加上线程进行异步请求,但是不会...

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);
</div>

</div>

您可能想查找下面的文章:

  • 教你如何将 Sublime 3 打造成 Python/Django IDE开发利器
  • python实现sublime3的less编译插件示例
  • python实现sublime3的less编译插件示例
  • netbeans7安装python插件的方法图解

相关文章

  • Ubuntu 16.04 LTS中源码安装Python 3.6.0的方法教程
  • python中日期和时间格式化输出的方法小结
  • Linux上安装Python的PIL和Pillow库处理图片的实例教程
  • python3读取MySQL-Front的MYSQL密码
  • Python Deque 模块使用详解
  • 跟老齐学Python之有容乃大的list(3)
  • python 循环while和for in简单实例
  • python通过索引遍历列表的方法
  • 跟老齐学Python之字典,你还记得吗?
  • 在Python中使用cookielib和urllib2配合PyQuery抓取网页信息

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 简单的Apache+FastCGI+Django配置指南
    • 浅析Python 中整型对象存储的位置
    • Python入门篇之条件、循环
    • Python ljust rjust center输出
    • Python中字典和JSON互转操作实例
    • Python装饰器入门学习教程(九步学习)
    • python实现搜索本地文件信息写入文件的方法
    • Python生成不重复随机值的方法
    • python中执行shell的两种方法总结
    • 深度定制Python的Flask框架开发环境的一些技巧总结

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有