def f(a,b,c,d=1,e="123"):
pass
if __name__ == '__main__':
print(f.__code__.co_filename)
print(f.__code__.co_code)
print(f.__code__.co_name)
print(f.__code__.co_varnames)
print(f.__code__.co_argcount)
print(f.__code__.co_kwonlyargcount)
print(f.__defaults__)
执行结果:
C:\Python36\python.exe C:/Users/fengl/Documents/GitHub/Spider/testng1.py
C:/Users/fengl/Documents/GitHub/Spider/testng1.py
b'd\x00S\x00'
f
('a', 'b', 'c', 'd', 'e')
5
0
(1, '123')
从co_code来反编译得出函数,这又是另外一个故事了。