Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

python - Why can't I use ._doc_ attribute for built in functions?

For example:

print(print._doc_)

this is the error I get:

PS D:GitHubMango> py temp.txt
Traceback (most recent call last):
  File "D:GitHubMangoemp.txt", line 1, in <module>
    print(print._doc_)
AttributeError: 'builtin_function_or_method' object has no attribute '_doc_'
question from:https://stackoverflow.com/questions/65930629/why-cant-i-use-doc-attribute-for-built-in-functions

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You want __doc__ (two underscores on either side):

>>> print(print.__doc__)
print(value, ..., sep=' ', end='
', file=sys.stdout, flush=False)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...