各自的作用:
doc:獲取到註釋內容
name:獲取到函數的名稱
file:獲取到當前的文件路徑(獲取模塊路徑)
示例代碼
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from win32gui import *
import timeit
titles = set()
def foo(hwnd,mouse):
"""
我是foo的註釋
"""
if IsWindow(hwnd) and IsWindowEnabled(hwnd) and IsWindowVisible(hwnd):
titles.add(GetWindowText(hwnd))
print("timeit.__doc__:",timeit.__doc__)
print("timeit.__name__:",timeit.__name__)
print("timeit.__file__:",timeit.__file__)
print("foo.__doc__:",foo.__doc__)
print("foo.__name__:",foo.__name__)
print("__file__:",__file__)
輸出結果
timeit.__doc__: Tool for measuring execution time of small code snippets.
This module avoids a number of common traps for measuring execution
times. See also Tim Peters' introduction to the Algorithms chapter in
the Python Cookbook, published by O'Reilly.
Library usage: see the