python yield

例如:

deftest():

withopen(r"D:/PythonCode/sequence_tagging-master/data/hhhh.txt")asfr:

forlineinfr:

line=line.strip()

yieldline

   

fori,xinenumerate(test()):

print(i,x)

   

   

原文地址:https://www.cnblogs.com/wuxiangli/p/10246751.html