作者anivia0428 (AniviaGod)
看板Python
标题[问题] 关於code object 转 function
时间Sat Nov 17 21:40:19 2018
大家好~
我现在遇到一个问题
我现在有一个
变数code_obj印出来是 : <code object test4 at 0x10a96e630, file "./tests/test.py", line 12>
test4长相如下:
def test4(a, b, const = 0, kk = False):
if(a > b):
return a
else:
return b
然後我执行test4 = FunctionType(code_obj, {})把它转成function後
执行 test4(123,1234) 却会告诉我说他要四个变数我只给两个变数
有人知道要怎麽解决吗?就是他会强迫我连预设的变数的位置都要输入
感谢~~
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 123.193.91.243
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1542462022.A.6BC.html
1F:推 ThxThx: print(FunctionType.__doc__)看用法 11/18 11:34
2F:→ ThxThx: 记得argdefs要传入tuple 11/18 11:34