當前位置:首頁 » 編程語言 » pythontab補全

pythontab補全

發布時間: 2022-03-05 01:36:30

python 怎麼補全linux

Python自動補全有vim編輯下和python交互模式下,下面分別介紹如何在這2種情況下實現Tab鍵自動補全。
一、vim python自動補全插件:pydiction
可以實現下面python代碼的自動補全:
簡單python關鍵詞補全
python 函數補全帶括弧
python 模塊補全
python 模塊內函數,變數補全
from mole import sub-mole 補全
想為vim啟動自動補全需要下載插件,地址如下:
http://vim.sourceforge.net/scripts/script.php?script_id=850
https://github.com/rkulla/pydiction
安裝配置:
wget https://github.com/rkulla/pydiction/archive/master.zip
unzip -q master
mv pydiction-master pydiction
mkdir -p ~/.vim/tools/pydiction
cp -r pydiction/after ~/.vim
cp pydiction/complete-dict ~/.vim/tools/pydiction

確保文件結構如下:
# tree ~/.vim
/root/.vim
├── after
│ └── ftplugin
│ └── python_pydiction.vim
└── tools
└── pydiction
└── complete-dict

創建~/.vimrc,確保其中內容如下:
# cat ~/.vimrc
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'

用vim編輯一個py文件,import os.,這時候應該出現提示,證明成功

二、python交互模式下Tab自動補齊
創建文件如下:
# cat ~/.pythonstartup
# python startup file
#!/usr/bin/env python
import sys
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)

del os, histfile, readline, rlcompleter
1

echo 'export PYTHONSTARTUP=~/.pythonstartup' >> ~/.bash_profile

重新登陸shell,輸入python命令進入交互模式,就可以用Tab鍵進行補全。

⑵ python idle自動補全功能

比如print的自動補全

輸入pr 按Tab鍵,彈出提示選項。 按空格就可以選擇第一個print
注意是 空格, 而不是回車

⑶ wins怎麼設置python的tab自動補全出錯

[root@abc ~]# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "right", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.6/site-packages/cloud_init-0.7.6-py2.6.egg', '/usr/lib/python2.6/site-packages/jsonpatch-1.13-py2.6.egg', '/usr/lib/python2.6/site-packages/requests-2.9.1-py2.6.egg', '/usr/lib/python2.6/site-packages/argparse-1.4.0-py2.6.egg', '/usr/lib/python2.6/site-packages/Jinja2-2.8-py2.6.egg', '/usr/lib/python2.6/site-packages/jsonpointer-1.10-py2.6.egg', '/usr/lib/python2.6/site-packages/six-1.10.0-py2.6.egg', '/usr/lib/python2.6/site-packages/AliyunUtil-0.0.1-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']

⑷ linux下的python ide怎麼設置tab補全

在Python模式交互下,tab自動補全會提高代碼效率,通過以下步驟可以很方便的實現自動補全。
1.獲取操作目錄
[root@liu site-packages]# pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "right", "credits" or "license" for more information.>>> import sys>>> sys.path
['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages']>>> 123456789

可以看出,我的工作目錄是/usr/lib/python2.6/site-packages/。
2.進入工作目錄,編寫tab.py補全文件
[root@liu site-packages]# cd /usr/lib/python2.6/site-packages/[root@liu site-packages]# vim tab.py 123

tab.py內容如下,建議粘貼的時候保證格式正確性
1 #!/usr/bin/python
2 # python tab file
3 import sys 4 import readline 5 import rlcompleter 6 import atexit 7 import os 8 # tab completion
9 readline.parse_and_bind('tab: complete') 10 # history file
11 histfile = os.path.join(os.environ['HOME'], '.pythonhistory') 12 try: 13 readline.read_history_file(histfile) 14 except IOError: 15 pass
16 atexit.register(readline.write_history_file, histfile) 17
18 del os, histfile, readline,

3.添加環境變數,使其生效
[root@liu site-packages]# cd [root@liu ~]# vim .bashrc123

在末尾添加一行
export PYTHONSTARTUP=/usr/lib/python2.6/site-packages/tab.py1

4.重讀.bashrc文件
source .bashrc1

或者
. .bashrc1

5.測試效果
[root@liu ~]# python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "right", "credits" or "license" for more information.
>>> import math>>> math.math.__class__( math.acos( math.fsum(math.__delattr__( math.acosh( math.hypot(math.__dict__ math.asin( math.isinf(math.__doc__ math.asinh( math.isnan(math.__file__ math.atan( math.ldexp(math.__format__( math.atan2( math.log(math.__getattribute__( math.atanh( math.log10(math.__hash__( math.ceil( math.log1p(math.__init__( math.sign( math.modf(math.__name__ math.cos( math.pimath.__new__( math.cosh( math.pow(math.__package__ math.degrees( math.radians(math.__rece__( math.e math.sin(math.__rece_ex__( math.exp( math.sinh(math.__repr__( math.fabs( math.sqrt(math.__setattr__( math.factorial( math.tan(math.__sizeof__( math.floor( math.tanh(math.__str__( math.fmod( math.trunc(math.__subclasshook__( math.frexp(
>>> math.

完成。我一開始一直報錯,然後通過排查就是因為tab.py格式不正確。注意其格式。

⑸ 如何在Vim中使用tab進行Python代碼補全

這里要介紹的功能叫"new-omni-completion(全能補全)", 你可以用下面的命令看看介紹: :help new-omni-completion 你還需要在~/.vimrc文件中增加下面兩句: filetype plugin indent on 打開文件類型檢測, 加了這句才可以用智能補全 set completeopt

⑹ python開發軟體中,除自帶的idle,哪一個支持第三方庫的tab自動補全

Python GUI 和PythonWin 都支持,個人感覺不太好用
看你用途,可以試試WingIDE,eclipse(需要裝pydev插件) ,aptana Studio(自帶pydev)

⑺ 如何在vim中使用tab進行python代碼補全

我這里要介紹的功能叫"new-omni-completion(全能補全)", 你可以用下面的命令看看介紹: :help new-omni-completion 你還需要在~/.vimrc文件中增加下面兩句: filetype plugin indent on 打開文件類型檢測, 加了這句才可以用智能補全 set completeo...

⑻ python中tab鍵怎麼用

這個鍵的意思是相當於四個空格,但是它不能和空格混用,不然會提示錯誤。

⑼ python tab補全是什麼意思

比如關鍵字,print,當你輸入pr時,按tab鍵,系統自動將int給你補上,就不用完整輸入print

⑽ 為何在ipython環境下按tab鍵無法自動完成,按了一直是縮進符

你這個ipython是單獨安裝的吧,需要安裝pyreadline。

熱點內容
隨機啟動腳本 發布:2025-07-05 16:10:30 瀏覽:532
微博資料庫設計 發布:2025-07-05 15:30:55 瀏覽:30
linux485 發布:2025-07-05 14:38:28 瀏覽:310
php用的軟體 發布:2025-07-05 14:06:22 瀏覽:760
沒有許可權訪問計算機 發布:2025-07-05 13:29:11 瀏覽:436
javaweb開發教程視頻教程 發布:2025-07-05 13:24:41 瀏覽:718
康師傅控流腳本破解 發布:2025-07-05 13:17:27 瀏覽:246
java的開發流程 發布:2025-07-05 12:45:11 瀏覽:692
怎麼看內存卡配置 發布:2025-07-05 12:29:19 瀏覽:288
訪問學者英文個人簡歷 發布:2025-07-05 12:29:17 瀏覽:837