小编che*_*ile的帖子

将函数存储为字典值时调用函数

def test():
     print "printing from test func"

dic = {'a':1,'b':2,'c':test}
if len(dic) == 3:
     print (dic['c'])

output:
<function test at 0x106887578>
Run Code Online (Sandbox Code Playgroud)

此代码打印函数对象作为输出,如何从测试函数获取print语句作为输出.

python python-2.7

3
推荐指数
1
解决办法
3186
查看次数

标签 统计

python ×1

python-2.7 ×1