定位到函式定義
在函式名處 ctrl + b
就會快速定位到函式定義處
在console中執行檔案
全選內容後,右鍵選單
execute selection in console
或者快捷鍵 alt + shift + e
設定工作目錄,這樣一些資料檔案可以用檔名快速訪問
>>>
import os
>>> os.chdir('c:\\githubrepositories\\pythonprojects\\ml2')
4.設定編譯目錄,可以直接在pythonconsole中load相關檔案
sys.path.extend(['c:\\githubrepositories\\pythonprojects\\ml2'])
python3.5 已經不能直接reload, 必須使用如下:
>>>
import importlib
>>> importlib.reload(knn)
如何讀取含有 環境變數的路徑 :
使用os.path.expandvars函式
os.path.expandvars(r」%windir%\fonts\simsun.ttc」)
參考如下:
python 3.5
string.format:
乙個例子:
將數字轉化為乙個顏色
"#".format(random.randint(0, 0xffffff))
引用:
python 3.5 annotation 在pycharm中的應用
注意在表示引數是 tuple,list時要先:
from typing import tuple
from typing import list
隨後寫如下語句:
def file_to_matrix(a_filename: str)-> tuple[ndarray, list, dict, list[str]]:
而不能寫
def file_to_matrix(a_filename: str)-> tuple[ndarray, list, dict, list[str]]:
否則會報錯:
def file_to_matrix(a_filename: str)-> tuple[ndarray, list, dict, list[str]]:
typeerror: 『type』 object is not subscriptable
頂
Pycharm的一些使用技巧
之前一直使用notepad 來寫程式,最近開始深入pycharm,發現很多亮點,不過也遇到一些問題,遂整理如下 個人偏好配置 git使用 2.配置賬號 3.操作方法 4.相關報錯即解決方法 待補充進入tools的deployment選項,選中configuration,新增sftp。如下圖所示 這個...
Pycharm中的一些技巧
作為乙個工具控,不來總結點pycharm的使用技巧怎麼行呢?1 遠端 編輯 除錯 這類使用情景就是,比如遠端機器是執行centos系統的伺服器,本地主機是安裝了pycharm的os x。要在本地寫 遠端機器上執行除錯。首先,新建乙個專案 目前還是乙個空專案 配置遠端python直譯器。並且設定ssh...
Pycharm的一些使用技巧(快捷鍵)
編輯類 ctrl space 基本的 完成 類 方法 屬性 end 移動到行尾 home 移動到行首 ctrl alt space 類名完成 ctrl shift enter 語句完成 ctrl p 引數資訊 在方法中呼叫引數 ctrl q 快速檢視文件 shift f1 外部文件 ctrl 滑鼠 ...