python實(shí)現(xiàn)sublime3的less編譯插件示例
利用http://tool.oschina.net/less 提供的接口,發(fā)送請(qǐng)求進(jìn)行遠(yuǎn)程編譯.
再將編譯好的less,保存為同名后綴為css的文件中.
第一次使用python,代碼也是拼拼湊湊的.需要加上線程進(jìn)行異步請(qǐng)求,但是不會(huì)...
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最新激活注冊(cè)碼分享適用2020最新版 親測(cè)可用
- 教你如何將 Sublime 3 打造成 Python/Django IDE開發(fā)利器
- win7 下搭建sublime的python開發(fā)環(huán)境的配置方法
- sublime text 3配置使用python操作方法
- SublimeText 2編譯python出錯(cuò)的解決方法(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)境的詳細(xì)教程
- Python sublime安裝及配置過程詳解
- 如何在sublime編輯器中安裝python
- sublime3之內(nèi)網(wǎng)安裝python插件Anaconda的流程
- 教你使用Sublime text3搭建Python開發(fā)環(huán)境及常用插件安裝另分享Sublime text3最新激活注冊(cè)碼
相關(guān)文章
python讀取.mat文件及將變量存為.mat文件的詳細(xì)介紹
這篇文章主要給大家介紹了關(guān)于python讀取.mat文件及將變量存為.mat文件的詳細(xì)介紹,?mat文件是matlab的數(shù)據(jù)存儲(chǔ)的標(biāo)準(zhǔn)格式,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-06-06
django數(shù)據(jù)庫遷移migration實(shí)現(xiàn)
這篇文章主要介紹了django數(shù)據(jù)庫遷移migration實(shí)現(xiàn),遷移任務(wù)是根據(jù)對(duì)models.py文件的改動(dòng)情況,添加或者刪除表和列,下面詳細(xì)的相關(guān)內(nèi)容需要的小伙伴可以參考一下2022-02-02
Python實(shí)現(xiàn)括號(hào)匹配方法詳解
這篇文章主要介紹了python實(shí)現(xiàn)括號(hào)匹配方法詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-02-02
Python實(shí)現(xiàn)老照片修復(fù)之上色小技巧
你會(huì)黑白照片上色嗎,今天小編帶你用python來給黑白照片上個(gè)色,這里我們借助百度AI開放平臺(tái)的“黑白圖像上色”接口,僅需二十行代碼即可實(shí)現(xiàn),感興趣的朋友來看看吧2021-10-10

