【python】解决:TypeError: can't send non-None value to a just-started generator
生活随笔
收集整理的這篇文章主要介紹了
【python】解决:TypeError: can't send non-None value to a just-started generator
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在一個生成器函數未啟動之前,是不能傳遞數值進去。必須先傳遞一個None進去或者調用一次next(g)方法,才能進行傳值操作
def product(c):# c.send(None)for i in range(5):print("生產者產生數據%d"%i)r= c.send(str(i))print("消費者消費了數據%s"%r)# c.close() def customer():data = ""while 1:n =yield dataif not n:returnprint("消費者消費了%s"%n)data= "200" c= customer() product(c)?
總結
以上是生活随笔為你收集整理的【python】解决:TypeError: can't send non-None value to a just-started generator的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux samba的配置和使用
- 下一篇: 算法竞赛入门经典笔记