是否可以将带有参数的函数传递给Python中的另一个函数?
比如说:
def perform(function):
return function()
Run Code Online (Sandbox Code Playgroud)
但要传递的函数将具有如下参数:
action1()
action2(p)
action3(p,r)
Run Code Online (Sandbox Code Playgroud) 我正在使用Python的日志记录模块,我想暂时禁用控制台日志记录,但它不起作用.
#!/usr/bin/python
import logging
logger = logging.getLogger() # this gets the root logger
# ... here I add my own handlers
#logger.removeHandler(sys.stdout)
#logger.removeHandler(sys.stderr)
print logger.handlers
# this will print [<logging.StreamHandler instance at ...>]
# but I may have other handlers there that I want to keep
logger.debug("bla bla")
Run Code Online (Sandbox Code Playgroud)
上面的代码显示了bla blaon stdout,我不知道如何安全地禁用控制台处理程序.我怎么能确定我暂时删除了控制台StreamHandler而不是另一个?