当生成器函数中含有return时,return不会返回任何值,会直接终止当前生成器,对yield的作用没有影响,当函数执行到return时候,调用next()来执行生成器则会报错,如果使用for循环遍历,for循环会自动捕获该异常,直接停止遍历 def func(): ): i += yield i # print(i) return i f = func() for i in f: print(i) f = func() next(f) # f.send() next(f) next(f) n
function aa1511() { var chengshi="马鞍山"; var shengfen="安徽省"; return shengfen+"@"+chengshi; } function xialachaxun() { var hanshu=aa1511().split("@"); alert(hanshu[0]+','+hanshu[1]); }
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <ti