python的dir、help、str用法

來源:互聯網
上載者:User

標籤:uil   cache   有用   顯示   函數   argv   package   isp   pack   

 

 

當你給dir()提供一個模組名字時,它返回在那個模組中定義的名字的列表。當沒有為其提供參數時, 它返回當前模組中定義的名字的列表。
dir() 函數使用舉例:

123456 >>> import sys  # 獲得屬性列表,在這裡是sys模組的屬性列表>>> dir(sys)[‘__displayhook__‘‘__doc__‘‘__excepthook__‘‘__name__‘‘__package__‘‘__stderr__‘‘__stdin__‘‘__stdout__‘‘_clear_type_cache‘‘_compact_freelists‘,‘_current_frames‘‘_getframe‘‘api_version‘‘argv‘, ...]

 

如果您需要快速擷取任何的Python函數或語句的資訊,那麼您可以使用內建的“help”(協助)功能。這是非常有用的,尤其是當使用翻譯提示符時,例如,運行‘help(print)”——這將顯示print函數的協助--用於列印東西到螢幕上。

help()函數使用舉例:

123456 >>> help(print)Help on built-in function print in module builtins: print(...)    print(value, ..., sep=‘ ‘, end=‘\n‘file=sys.stdout, flush=False)...

python的dir、help、str用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.