有關Python的內建函數:dir()與help(),常常一堆人搞不清楚,今天就來見真章! Python 中 dir()、help()的使用 想要使用 Python 來編寫程式碼時,經常會選擇使用 Python 中的內建函數 (Built-in Functions)或是模組。如果遇到對一些函數、模組不清楚的情形,則可以通過 dir() 和 help() 查詢說明或屬性。 help(): 用於查看屬性及方法的詳細解釋 Python 內建函數 - dir() 「dir()」的用途,是用於查詢物件的全部屬性。例如今天你想使用 dir() 函數用於查看物件「str」 的全部屬性,你就寫了: >>>print dir(str) 執行結果如下: ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__...