小编Evg*_*eny的帖子

Python中不可思议的"除外"加注

请帮助python脚本.Python 2.7.我尝试使用错误检查重复操作的一些功能.所以在我认为的函数中我调用下面(lib_func),没有错误.但是在转发器()中的"除了"以任何方式提升.

如果我不在lib_func()中使用"x" - 它可以正常工作,但我仍然需要在lib_func()中输入参数.

对不起英语不好,并提前感谢您的帮助.

def error_handler():
    print ('error!!!!!!')

def lib_func(x):
    print ('lib_func here! and x = ' + str(x))

def repeater(some_function):
    for attempts in range(0, 2):
        try:
            some_function()
        except:
            if attempts == 1:
                error_handler()
            else:
                continue
    break
return some_function

repeater(lib_func(10))
Run Code Online (Sandbox Code Playgroud)

输出:

lib_func here! and x = 10
error!!!!!!

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

python wrapper python-2.7

2
推荐指数
1
解决办法
58
查看次数

标签 统计

python ×1

python-2.7 ×1

wrapper ×1