Python學習 第3天 VS與PyCharm使用對比

前兩天出差,趁着熱情再玩玩Python吧python

IDE就在VS和Pycharm中選吧,這兩個IDE都很喜歡session

 

1、VSapp

能在VS中開發Python是最好,平時習慣了。能夠安裝PTVS,直接新建個Python項目,就會提示下載PTVS了,安裝完試了下:字體

一、直接新建文件,選擇python,建了個.py文件,是不能運行和調試的,點那個【Execute Project in Python Interactive】也有問題,要新建項目才能夠spa

 

二、開頭不用# encoding: utf-8 也能夠支持中文,運行出來的Python窗口能正確顯示中文。網上說插件

默認的選擇是「簡體中文(GB18030) - 代碼頁 54936」
要替換爲「Unicode (UTF-8 無簽名) - 代碼頁 65001」

但我試了剛好相反,默認的是GB2312正常,要是改爲了UTF-8,反而亂碼了調試

 

三、下斷點後調試很是親切,和平時開發C#同樣,快速監視也能夠用code

 

四、沒有智能提示,去網上下了一個Python intellisense Enhancer,結果打字是反的來的。。。就是要打print,就變成tnirp。。。orm

找了半天,原來是這個插件每次輸入文字就觸發Ctrl + J,這個快捷鍵默認是列出成員,即智能提示,但你們快捷鍵可能會改啊,我就是改爲左移字符。。。什麼鬼,每次輸入都觸發智能提示,雖然能達到效果,感受怪怪的。。。blog

https://pyint.codeplex.com/workitem/1619
Right now the Python Intellisense Explorer is initiating and Intellisense session by sending the key stroke Ctrl+J to Visual Studio. This generally works but suffers from a couple of reliability issues in non-standard cases 
Ctrl+J isn't always mapped to display Intellisense. Users are free to bind the Intellisense command (Edit.ListMembers) to other key values
In the case Ctrl+J isn't mapped to Edit.ListMembers it will be interpreted as a literal key stroke and cause spurious new lines to be inserted into the code base. 

若是不下這個插件的話,要提示要手動按下Ctrl + J(或自定義的其它快捷鍵來觸發【列出成員】)也是能夠

 =================

網上找了段代碼,註釋掉放在前面,對着敲了一遍,感受智能提示仍是能夠的,也不必太在乎它的實現方式,事實上,它官網也說明了它的原理,就是輸個字觸發下Ctrl + J。。。不過實際使用中感受不出什麼,仍是很順暢的:

OpenSource Project Link:

https://pyint.codeplex.com/
 

Implementation Detail

It's a simple editor extension listening text change event. It just simulate the key stroke ( Ctrl + J ) to show the intellisense box.

 

 

2、PyCharm

代碼提示完善許多,格式化代碼也強大些,是一套完整的IDE,若是沒有VS用這個足夠了,但已有VS就感受有些重複,畢竟VS用習慣了,又有一堆自定義的快捷鍵用的順手,換成PyCharm又要從新設置一遍快捷鍵,包括代碼字體顏色什麼的,好麻煩,不是專業開發Python的,偶爾玩一玩仍是用VS算了。

 

並且之後VS和Resharper說不定對Python支持愈來愈多。就像之前寫UI層有試過一下WebStorm,新鮮了一陣仍是用回VS。

相關文章
相關標籤/搜索