Linux 拨号vps windows公众号手机端

怎么看python函数源代码

lewis 6年前 (2019-04-08) 阅读数 17 #程序编程
文章标签 python

在python中使用inspect.getsource函数查看函数源代码,具体方法如下:

import inspect

def print_hh():

print('hh')

source = inspect.getsource(print_hh) # 查看自定义函数print_hh的源代码

print(source)

输出结果为:

def print_hh():

print('hh')

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门