欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

pythondocstring是什么意思

本篇文章給大家分享的是有關(guān)python docstring是什么意思,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

創(chuàng)新互聯(lián)公司提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計,品牌網(wǎng)站設(shè)計,1元廣告等致力于企業(yè)網(wǎng)站建設(shè)與公司網(wǎng)站制作,10余年的網(wǎng)站開發(fā)和建站經(jīng)驗,助力企業(yè)信息化建設(shè),成功案例突破近1000家,是您實現(xiàn)網(wǎng)站建設(shè)的好選擇.

Docstring是一種文檔字符串,用于解釋構(gòu)造的作用。我們在函數(shù)、類或方法中將它放在首位來描述其作用。我們用三個單引號或雙引號來聲明docstring。

>>> def sayhi():
 """
用該函數(shù)打印Hi
"""
 print("Hi") 
>>> sayhi()
Hi

要想獲取一個函數(shù)的docstring,我們使用它的_doc_屬性

>>> sayhi.__doc__
‘
  This function prints Hi
’

docstring,不僅可以編寫代碼,同時也能寫出文檔,保持代碼和文檔的一致。

docstring說白了就是一堆代碼中的注釋。

Python的docstring可以通過help函數(shù)直接輸出一份有格式的文檔。

編寫test.py

def printMax(x, y):
    '''Prints the maximum of two numbers.
    The two values must be integers.'''
    x = int(x) # convert to integers, if possible
    y = int(y)
    if x > y:
         print (x, 'is maximum')
    else:
         print (y, 'is maximum')
printMax(3, 5)
print (printMax.__doc__)

命令行輸入 help(test)

import test
5 is maximum
Prints the maximum of two numbers.
    The two values must be integers.
help(test)
Help on module test:
NAME
    test - Created on Sat Jun  2 19:05:08 2018
DESCRIPTION
    @author: linzhiwei02
FUNCTIONS
    printMax(x, y)
        Prints the maximum of two numbers.
        The two values must be integers.
FILE
    /Users/linzhiwei02/Desktop/test.py

以上就是python docstring是什么意思,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章名稱:pythondocstring是什么意思
瀏覽路徑:http://chinadenli.net/article44/pghoee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司網(wǎng)站營銷、搜索引擎優(yōu)化App設(shè)計、電子商務(wù)動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)