【发布时间】:2016-09-07 20:54:13
【问题描述】:
是否可以查看方法究竟是如何工作的?例如列表方法 count()。 我有一个清单:
li = [3, 5, 6, 7, 3, 3, 3]
当我输入时
print li.count(3)
输出将是 4。我怎样才能看到发生这种魔法的代码? 命令 help(list.count) 给出的信息不足:
>>> help(list.count)
Help on method_descriptor:
count(...)
L.count(value) -> integer -- return number of occurrences of value
【问题讨论】:
-
help(list.count),阅读documentation 或查看the source。 -
你试过用谷歌搜索 Python 的源代码吗?
-
是的,我试图在 Google 中找到此代码。但我没有成功。
标签: python