sublime外掛程式開發教程1

2022-03-04 06:48:40 字數 1770 閱讀 1293

sublime外掛程式是用python開發的  所以學習sublime之前 先學習python語法  不然**看不懂

1 編碼統一要用utf8 這樣輸出中文才不會亂碼

#!/usr/bin/python

# -*- coding: utf-8 -*-print (

"你好,世界

")

2 變數跟js比較像(這個地方+要注意 型別要一致)

#!/usr/bin/python

# -*- coding: utf-8 -*-dd="

dsdd

"print (

"你好,

"+dd+"

世界")

3 python字典(也跟js比較像)

dict ={}

dict[

'one

'] = "

this is one

"print dict

4 python條件語句(小括號大括號都省了。。能省的都省了 造成了可讀性很差 是python的一大缺陷)

注意 他的大括號變成冒號了。。

flag =false

name = '

luren

'if name == '

python

': # 判斷變數是否為 python

flag =true # 條件成立時設定標誌為真

print

'welcome boss

'# 並輸出歡迎資訊

else

: print name # 條件不成立時輸出變數名稱

下面再看個for

#!/usr/bin/python

# -*- coding: utf-8 -*-

for letter in

'python

': # 第乙個例項

print

'當前字母 :

', letter

fruits = ['

banana

', '

', '

mango']

for fruit in

fruits: # 第二個例項

print

'當前水果 :

', fruit

print

"good bye!

"

再看函式(也是大括號變成冒號)

#!/usr/bin/python

# -*- coding: utf-8 -*-# 定義函式

def printme( str ):

"列印任何傳入的字串

"print str;

return;

# 呼叫函式

printme(

"我要呼叫使用者自定義函式!");

printme(

"再次呼叫同一函式

");

4 呼叫python模組(有點像類裡面靜態函式)

#!/usr/bin/python

# -*- coding: utf-8 -*-# 匯入模組

import support

# 現在可以呼叫模組裡包含的函式了

support.print_func(

"runoob

")

總結 python**是最簡潔的

sublime外掛程式開發教程4

寫幾個簡單的例子詳解下 import sublime import sublime plugin class examplecommand sublime plugin.textcommand def run self,edit sels self.view.sel for sel in sels ...

sublime外掛程式開發教程2

直接進入正題 先新建個chajian.py python寫起 import sublime import sublime plugin class examplecommand sublime plugin.textcommand defrun self,edit self.view.insert ...

sublime 外掛程式安裝

import urllib2,os pf package control.sublime package ipp sublime.installed packages path os.makedirs ipp if not os.path.exists ipp else none urllib2.i...