# -*- coding: utf-8 -*-


def gen_func():
    # 生成器不只可以产出值，还可以接收值(调用方传递进来的值)。
    try:
        yield "http://kuaixun.stcn.com/index.shtml"
    except Exception as e:
        pass
    yield 2
    yield 3
    return 'Tom'


if __name__ == '__main__':
    gen = gen_func()
    print(next(gen))
    gen.throw(Exception, 'download_error')
    print(next(gen))
    gen.throw(Exception, 'download_error')

2bc26bfc48ca9d6dcdb2a37805510d5050c4cc2c
<mask token>

def gen_func():
    try:
        yield 'http://kuaixun.stcn.com/index.shtml'
    except Exception as e:
        pass
    yield 2
    yield 3
    return 'Tom'


<mask token>

def gen_func():
    try:
        yield 'http://kuaixun.stcn.com/index.shtml'
    except Exception as e:
        pass
    yield 2
    yield 3
    return 'Tom'


if __name__ == '__main__':
    gen = gen_func()
    print(next(gen))
    gen.throw(Exception, 'download_error')
    print(next(gen))
    gen.throw(Exception, 'download_error')

# -*- coding: utf-8 -*-


def gen_func():
    # 生成器不只可以产出值，还可以接收值(调用方传递进来的值)。
    try:
        yield "http://kuaixun.stcn.com/index.shtml"
    except Exception as e:
        pass
    yield 2
    yield 3
    return 'Tom'


if __name__ == '__main__':
    gen = gen_func()
    print(next(gen))
    gen.throw(Exception, 'download_error')
    print(next(gen))
    gen.throw(Exception, 'download_error')
