亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

python中的_doc_是什么

python中的_doc_是什么

婷婷同學_ 2018-07-05 09:09:20
查看完整描述

1 回答

?
aluckdog

TA貢獻1847條經驗 獲得超7個贊

文檔字符串。注意,是?__doc__?,前后各兩個下劃線。

一般而言,是對函數/方法/模塊所實現功能的簡單描述。但當指向具體對象時,會顯示此對象從屬的類型的的文檔字符串。(示例見以下?a.__doc__)

>>>?str.__doc__
"str(string[,?encoding[,?errors]])?->?str\n\nCreate?a?new?string?object?from?the?given?encoded?string.\nencoding?defaults?to?the?current?default?string?encoding.\nerrors?can?be?'strict',?'replace'?or?'ignore'?and?defaults?to?'strict'."

>>>?import?math
>>>?math.__doc__
'This?module?is?always?available.??It?provides?access?to?the\nmathematical?functions?defined?by?the?C?standard.'

>>>?a?=?[1]

>>>?a.count.__doc__
'L.count(value)?->?integer?--?return?number?of?occurrences?of?value'
>>>?a.__doc__
"list()?->?new?empty?list\nlist(iterable)?->?new?list?initialized?from?iterable's?items"

為自定義的函數創建?__doc__?的方法示例:

>>>?def?func():
????"""Here's?a?doc?string"""
????pass
>>>?func.__doc__
"Here's?a?doc?string"


查看完整回答
反對 回復 2018-07-26
  • 1 回答
  • 0 關注
  • 1807 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號