All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Login


All New Login

All gists matching topic inspect

Recently created
Least recently created
Recently updated
Least recently updated

timmy / 使用 inspect 來獲取函式與類別的詳細資訊

0 likes
0 forks
3 files
Last active 9 months ago
inspect 模組允許在執行時動態獲取函式、類別、模組的結構與資訊,適用於 除錯、程式碼分析、自動文件生成、動態調試 等場景。
debugging inspect introspection python reflection
1 import inspect
2
3 def example_function(a: int, b: str = "default") -> bool:
4 """示範函式,回傳 True 或 False"""
5 return bool(a)
6
7 # 獲取函式參數
8 signature = inspect.signature(example_function)
9 print(f"函式簽名: {signature}")
Newer Older

Powered by Opengist ⋅ Load: 41ms⋅

日本語
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文