def psychologist():
print 'Please tell me your problems'
while True:
answer = (yield)
if answer is not None:
if answer.endswith('?'):
print ("Don't ask yourself too much questions")
elif 'good' in answer:
print "A that's good, go on"
elif 'bad' in answer:
print "Don't be so negative"
free = psychologist()
free.next()
#Please tell me your problems
free.send('I feel bad')
#Don't be so negative
free.send("Why I shouldn't ?")
#Don't ask yourself too much questions
free.send("ok then i should find what is good for me")
#A that's good, go on
python yield send
最新推荐文章于 2022-11-17 21:29:02 发布