Python协程

2015-05-17 0 704
Python协程
def thread1():  
    for x in range(4):  
        yield x  
          
  
def thread2():  
    for x in range(4,8):  
        yield x  
          
  
threads=[]  
threads.append(thread1())  
threads.append(thread2())  
  
  
def run(threads):  
    for t in threads:  
        try:  
            print t.next()  
        except StopIteration:  
            pass  
        else:  
            threads.append(t)   
  
run(threads)  

遇见资源网 python Python协程 http://www.ox520.com/15350.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务