python相關小技巧(保持更新),python小技巧
1、查看匯入庫的類屬性、方法
python有一點感覺特別不方便的就是,不像C++指定了類型後,該類型的執行個體打個“.”會智能提示它含有的方法或屬性
之前都是靠查看庫對應的官方文檔解決。這次才發現了一個新方法 help,可以列出方法和屬性了
import dlibhelp(dlib.rectangles)Help on class rectangle in module dlib:class rectangle(pybind11_builtins.pybind11_object) | This object represents a rectangular area of an image. | | Method resolution order: | rectangle | pybind11_builtins.pybind11_object | builtins.object | | Methods defined here: | | __eq__(...) | __eq__(self: dlib.rectangle, arg0: dlib.rectangle) -> bool | | __getstate__(...) | __getstate__(self: dlib.rectangle) -> tuple | | __init__(...) | __init__(self: dlib.rectangle, left: int, top: int, right: int, bottom: int) -> None | | __ne__(...)
2、跳轉至函數定義的原始碼處
使用pycharm,按住CTRL,點擊函數,會跳轉至函數定義處
3、定義定長數組
import numpy as nphighlights_add = highlights_sub = np.zeros(256, dtype=np.float64)