Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> Python

Python में बिल्ट-इन क्लास एट्रिब्यूट __doc__ क्या करता है?

सभी फंक्शन्स में एक बिल्ट-इन एट्रिब्यूट __doc__ होता है, जो फंक्शन सोर्स कोड में परिभाषित डॉक स्ट्रिंग लौटाता है।

def foo():
    """ This is an example of how a doc_string looks like.
        This string gives useful information about the function being defined.
    """
    pass

print(foo.__doc__)

आइए देखें कि जब हम इसे प्रिंट करते हैं तो यह कैसा दिखेगा:

This is an example of how a doc_string looks like.
    This string gives useful information about the function being defined.
  1. - Python Bytestring क्या है?

    Python Bytestring एक String Characters का Sequence होता है; ये एक Abstract Concept हैं और इन्हें Directly Disk पर Store नहीं किया जा सकता। एक Byte String Bytes का Sequence होती है - ऐसी चीजें जो Disk पर Store की जा सकती हैं। इनके बीच Mapping को Encoding कहते हैं - इनमें से काफी सारे हैं (और अनंत सं

  1. - Python में Strings पर % Operator क्या करता है?

    % String Formatting Operator % एक String Formatting Operator या Interpolation Operator है। दिए गए format % values (जहां Format एक String है), Format में % Conversion Specifications को Values के Zero या अधिक Elements से Replace किया जाता है। Effect C Language में sprintf() का उपयोग करने के समान है।

  1. - पायथन में स्ट्रिंग लिटरल के सामने 'b' कैरेक्टर क्या करता है?

    पायथन 2 में b या B प्रीफिक्स को नजरअंदाज किया जाता है। पायथन 3 में, बाइट्स लिटरल्स हमेशा b या B से प्रीफिक्स्ड होते हैं; वे str टाइप के बजाय bytes टाइप का एक इंस्टेंस उत्पन्न करते हैं। उनमें केवल ASCII कैरेक्टर्स हो सकते हैं; 128 या अधिक न्यूमेरिक मान वाले बाइट्स को एस्केप के साथ व्यक्त किया जाना चा