python實現(xiàn)sublime3的less編譯插件示例
利用http://tool.oschina.net/less 提供的接口,發(fā)送請求進行遠程編譯.
再將編譯好的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);
- Sublime Text3最新激活注冊碼分享適用2020最新版 親測可用
- 教你如何將 Sublime 3 打造成 Python/Django IDE開發(fā)利器
- win7 下搭建sublime的python開發(fā)環(huán)境的配置方法
- sublime text 3配置使用python操作方法
- SublimeText 2編譯python出錯的解決方法(The system cannot find the file specified)
- ubuntu安裝sublime3并配置python3環(huán)境的方法
- sublime python3 輸入換行不結(jié)束的方法
- 解決sublime+python3無法輸出中文的問題
- Sublime開發(fā)python程序的示例代碼
- Python和Sublime整合過程圖示
- 在Sublime Editor中配置Python環(huán)境的詳細教程
- Python sublime安裝及配置過程詳解
- 如何在sublime編輯器中安裝python
- sublime3之內(nèi)網(wǎng)安裝python插件Anaconda的流程
- 教你使用Sublime text3搭建Python開發(fā)環(huán)境及常用插件安裝另分享Sublime text3最新激活注冊碼
相關(guān)文章
python讀取.mat文件及將變量存為.mat文件的詳細介紹
這篇文章主要給大家介紹了關(guān)于python讀取.mat文件及將變量存為.mat文件的詳細介紹,?mat文件是matlab的數(shù)據(jù)存儲的標準格式,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2024-06-06
django數(shù)據(jù)庫遷移migration實現(xiàn)
這篇文章主要介紹了django數(shù)據(jù)庫遷移migration實現(xiàn),遷移任務(wù)是根據(jù)對models.py文件的改動情況,添加或者刪除表和列,下面詳細的相關(guān)內(nèi)容需要的小伙伴可以參考一下2022-02-02

