Python怎么return后让循环继续运行? python中写完一个循环后,怎么退出并执行循环??

Python\u600e\u4e48return\u540e\u8ba9\u5faa\u73af\u7ee7\u7eed\u8fd0\u884c

return \u4f1a\u76f4\u63a5\u53e6\u51fd\u6570\u8fd4\u56de\uff0c\u51fd\u6570\u5c31\u8fd0\u884c\u7ed3\u675f\u4e86\uff0c\u6240\u6709\u8be5\u51fd\u6570\u4f53\u5185\u7684\u4ee3\u7801\u90fd\u4e0d\u518d\u6267\u884c\u4e86\uff0c\u6240\u4ee5\u8be5\u51fd\u6570\u4f53\u5185\u7684\u5faa\u73af\u4e5f\u4e0d\u53ef\u80fd\u518d\u7ee7\u7eed\u8fd0\u884c\u3002

\u5982\u679c\u4f60\u9700\u8981\u8ba9\u5faa\u73af\u7ee7\u7eed\u6267\u884c\uff0c\u5c31\u4e0d\u80fdreturn\u51fd\u6570\uff0c\u800c\u5e94\u8be5\u9009\u7528break\u6216\u8005continue\u3002
break\uff1a\u8df3\u51fa\u6240\u5728\u7684\u5f53\u524d\u6574\u4e2a\u5faa\u73af\uff0c\u5230\u5916\u5c42\u4ee3\u7801\u7ee7\u7eed\u6267\u884c\u3002
continue\uff1a\u8df3\u51fa\u672c\u6b21\u5faa\u73af\uff0c\u4ece\u4e0b\u4e00\u4e2a\u8fed\u4ee3\u7ee7\u7eed\u8fd0\u884c\u5faa\u73af\uff0c\u5185\u5c42\u5faa\u73af\u6267\u884c\u5b8c\u6bd5\uff0c\u5916\u5c42\u4ee3\u7801\u7ee7\u7eed\u8fd0\u884c\u3002
return\uff1a\u76f4\u63a5\u8fd4\u56de\u51fd\u6570\uff0c\u6240\u6709\u8be5\u51fd\u6570\u4f53\u5185\u7684\u4ee3\u7801\uff08\u5305\u62ec\u5faa\u73af\u4f53\uff09\u90fd\u4e0d\u4f1a\u518d\u6267\u884c\u3002

>>> for eachNum in range(3):... print eachNum # \u5199\u5b8c\u540e\u6572\u4e24\u4e2a\u56de\u8f66... 012>>> # \u4e0b\u4e00\u4e2a\u7a0b\u5e8f\u5f00\u59cb\u5982\u679c\u89e3\u51b3\u4e86\u60a8\u7684\u95ee\u9898\u8bf7\u91c7\u7eb3\uff01\u5982\u679c\u672a\u89e3\u51b3\u8bf7\u7ee7\u7eed\u8ffd\u95ee

return 会直接另函数返回,函数就运行结束了,所有该函数体内的代码都不再执行了,所以该函数体内的循环也不可能再继续运行。

如果你需要让循环继续执行,就不能return函数,而应该选用break或者continue。
break:跳出所在的当前整个循环,到外层代码继续执行。
continue:跳出本次循环,从下一个迭代继续运行循环,内层循环执行完毕,外层代码继续运行。
return:直接返回函数,所有该函数体内的代码(包括循环体)都不会再执行。

用下边的示例代码来解释:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

def return_continue_break(type):
if(not type in ["return", "continue", "break"]):
print '"type" should be "return, continue, break".'
return
for j in range(0, 10):
for i in range(0, 10):
print "j_i: %d_%d" %(j, i)
if(i > 3):
if(type == "return"):
return
elif(type == "continue"):
continue
else:
break
print "executed!"

if __name__ == '__main__':
return_continue_break("break")
return_continue_break("continue")
return_continue_break("return")

BREAK的输出为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

j_i: 0_0
executed!
j_i: 0_1
executed!
j_i: 0_2
executed!
j_i: 0_3
executed!
j_i: 0_4
j_i: 1_0
executed!
j_i: 1_1
executed!
j_i: 1_2
executed!
j_i: 1_3
executed!
j_i: 1_4
j_i: 2_0
executed!
j_i: 2_1
executed!
j_i: 2_2
executed!
j_i: 2_3
executed!
j_i: 2_4
j_i: 3_0
executed!
j_i: 3_1
executed!
j_i: 3_2
executed!
j_i: 3_3
executed!
j_i: 3_4
j_i: 4_0
executed!
j_i: 4_1
executed!
j_i: 4_2
executed!
j_i: 4_3
executed!
j_i: 4_4
j_i: 5_0
executed!
j_i: 5_1
executed!
j_i: 5_2
executed!
j_i: 5_3
executed!
j_i: 5_4
j_i: 6_0
executed!
j_i: 6_1
executed!
j_i: 6_2
executed!
j_i: 6_3
executed!
j_i: 6_4
j_i: 7_0
executed!
j_i: 7_1
executed!
j_i: 7_2
executed!
j_i: 7_3
executed!
j_i: 7_4
j_i: 8_0
executed!
j_i: 8_1
executed!
j_i: 8_2
executed!
j_i: 8_3
executed!
j_i: 8_4
j_i: 9_0
executed!
j_i: 9_1
executed!
j_i: 9_2
executed!
j_i: 9_3
executed!
j_i: 9_4

RETURN的输出为:

1
2
3
4
5
6
7
8
9

j_i: 0_0
executed!
j_i: 0_1
executed!
j_i: 0_2
executed!
j_i: 0_3
executed!
j_i: 0_4

CONTINUE的输出为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

j_i: 0_0
executed!
j_i: 0_1
executed!
j_i: 0_2
executed!
j_i: 0_3
executed!
j_i: 0_4
j_i: 0_5
j_i: 0_6
j_i: 0_7
j_i: 0_8
j_i: 0_9
j_i: 1_0
executed!
j_i: 1_1
executed!
j_i: 1_2
executed!
j_i: 1_3
executed!
j_i: 1_4
j_i: 1_5
j_i: 1_6
j_i: 1_7
j_i: 1_8
j_i: 1_9
j_i: 2_0
executed!
j_i: 2_1
executed!
j_i: 2_2
executed!
j_i: 2_3
executed!
j_i: 2_4
j_i: 2_5
j_i: 2_6
j_i: 2_7
j_i: 2_8
j_i: 2_9
j_i: 3_0
executed!
j_i: 3_1
executed!
j_i: 3_2
executed!
j_i: 3_3
executed!
j_i: 3_4
j_i: 3_5
j_i: 3_6
j_i: 3_7
j_i: 3_8
j_i: 3_9
j_i: 4_0
executed!
j_i: 4_1
executed!
j_i: 4_2
executed!
j_i: 4_3
executed!
j_i: 4_4
j_i: 4_5
j_i: 4_6
j_i: 4_7
j_i: 4_8
j_i: 4_9
j_i: 5_0
executed!
j_i: 5_1
executed!
j_i: 5_2
executed!
j_i: 5_3
executed!
j_i: 5_4
j_i: 5_5
j_i: 5_6
j_i: 5_7
j_i: 5_8
j_i: 5_9
j_i: 6_0
executed!
j_i: 6_1
executed!
j_i: 6_2
executed!
j_i: 6_3
executed!
j_i: 6_4
j_i: 6_5
j_i: 6_6
j_i: 6_7
j_i: 6_8
j_i: 6_9
j_i: 7_0
executed!
j_i: 7_1
executed!
j_i: 7_2
executed!
j_i: 7_3
executed!
j_i: 7_4
j_i: 7_5
j_i: 7_6
j_i: 7_7
j_i: 7_8
j_i: 7_9
j_i: 8_0
executed!
j_i: 8_1
executed!
j_i: 8_2
executed!
j_i: 8_3
executed!
j_i: 8_4
j_i: 8_5
j_i: 8_6
j_i: 8_7
j_i: 8_8
j_i: 8_9
j_i: 9_0
executed!
j_i: 9_1
executed!
j_i: 9_2
executed!
j_i: 9_3
executed!
j_i: 9_4
j_i: 9_5
j_i: 9_6
j_i: 9_7
j_i: 9_8
j_i: 9_9

return 会直接另函数返回,函数就运行结束了,所有该函数体内的代码都不再执行了,所以该函数体内的循环也不可能再继续运行。

如果你需要让循环继续执行,就不能return函数,而应该选用break或者continue。
break:跳出所在的当前整个循环,到外层代码继续执行。
continue:跳出本次循环,从下一个迭代继续运行循环,内层循环执行完毕,外层代码继续运行。
return:直接返回函数,所有该函数体内的代码(包括循环体)都不会再执行。

用下边的示例代码来解释:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

def return_continue_break(type):
if(not type in ["return", "continue", "break"]):
print '"type" should be "return, continue, break".'
return
for j in range(0, 10):
for i in range(0, 10):
print "j_i: %d_%d" %(j, i)
if(i > 3):
if(type == "return"):
return
elif(type == "continue"):
continue
else:
break
print "executed!"

if __name__ == '__main__':
return_continue_break("break")
return_continue_break("continue")
return_continue_break("return")

BREAK的输出为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

j_i: 0_0
executed!
j_i: 0_1
executed!
j_i: 0_2
executed!
j_i: 0_3
executed!
j_i: 0_4
j_i: 1_0
executed!
j_i: 1_1
executed!
j_i: 1_2
executed!
j_i: 1_3
executed!
j_i: 1_4
j_i: 2_0
executed!
j_i: 2_1
executed!
j_i: 2_2
executed!
j_i: 2_3
executed!
j_i: 2_4
j_i: 3_0
executed!
j_i: 3_1
executed!
j_i: 3_2
executed!
j_i: 3_3
executed!
j_i: 3_4
j_i: 4_0
executed!
j_i: 4_1
executed!
j_i: 4_2
executed!
j_i: 4_3
executed!
j_i: 4_4
j_i: 5_0
executed!
j_i: 5_1
executed!
j_i: 5_2
executed!
j_i: 5_3
executed!
j_i: 5_4
j_i: 6_0
executed!
j_i: 6_1
executed!
j_i: 6_2
executed!
j_i: 6_3
executed!
j_i: 6_4
j_i: 7_0
executed!
j_i: 7_1
executed!
j_i: 7_2
executed!
j_i: 7_3
executed!
j_i: 7_4
j_i: 8_0
executed!
j_i: 8_1
executed!
j_i: 8_2
executed!
j_i: 8_3
executed!
j_i: 8_4
j_i: 9_0
executed!
j_i: 9_1
executed!
j_i: 9_2
executed!
j_i: 9_3
executed!
j_i: 9_4

RETURN的输出为:

1
2
3
4
5
6
7
8
9

j_i: 0_0
executed!
j_i: 0_1
executed!
j_i: 0_2
executed!
j_i: 0_3
executed!
j_i: 0_4

CONTINUE的输出为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

j_i: 0_0
executed!
j_i: 0_1
executed!
j_i: 0_2
executed!
j_i: 0_3
executed!
j_i: 0_4
j_i: 0_5
j_i: 0_6
j_i: 0_7
j_i: 0_8
j_i: 0_9
j_i: 1_0
executed!
j_i: 1_1
executed!
j_i: 1_2
executed!
j_i: 1_3
executed!
j_i: 1_4
j_i: 1_5
j_i: 1_6
j_i: 1_7
j_i: 1_8
j_i: 1_9
j_i: 2_0
executed!
j_i: 2_1
executed!
j_i: 2_2
executed!
j_i: 2_3
executed!
j_i: 2_4
j_i: 2_5
j_i: 2_6
j_i: 2_7
j_i: 2_8
j_i: 2_9
j_i: 3_0
executed!
j_i: 3_1
executed!
j_i: 3_2
executed!
j_i: 3_3
executed!
j_i: 3_4
j_i: 3_5
j_i: 3_6
j_i: 3_7
j_i: 3_8
j_i: 3_9
j_i: 4_0
executed!
j_i: 4_1
executed!
j_i: 4_2
executed!
j_i: 4_3
executed!
j_i: 4_4
j_i: 4_5
j_i: 4_6
j_i: 4_7
j_i: 4_8
j_i: 4_9
j_i: 5_0
executed!
j_i: 5_1
executed!
j_i: 5_2
executed!
j_i: 5_3
executed!
j_i: 5_4
j_i: 5_5
j_i: 5_6
j_i: 5_7
j_i: 5_8
j_i: 5_9
j_i: 6_0
executed!
j_i: 6_1
executed!
j_i: 6_2
executed!
j_i: 6_3
executed!
j_i: 6_4
j_i: 6_5
j_i: 6_6
j_i: 6_7
j_i: 6_8
j_i: 6_9
j_i: 7_0
executed!
j_i: 7_1
executed!
j_i: 7_2
executed!
j_i: 7_3
executed!
j_i: 7_4
j_i: 7_5
j_i: 7_6
j_i: 7_7
j_i: 7_8
j_i: 7_9
j_i: 8_0
executed!
j_i: 8_1
executed!
j_i: 8_2
executed!
j_i: 8_3
executed!
j_i: 8_4
j_i: 8_5
j_i: 8_6
j_i: 8_7
j_i: 8_8
j_i: 8_9
j_i: 9_0
executed!
j_i: 9_1
executed!
j_i: 9_2
executed!
j_i: 9_3
executed!
j_i: 9_4
j_i: 9_5
j_i: 9_6
j_i: 9_7
j_i: 9_8
j_i: 9_9

这就是生成器的作用,如:

def func1():
    for i in range(10):
        yield i


for a in func1():
    print a

函数运行到return会自动返回,不再运行该函数

使用生成器,可以通过迭代生成器,继续执行函数剩下的部分

上代码执行的输出为:

0

1

2

3

4

5

6

7

8

9


Process finished with exit code 0



  • python鍑芥暟鐨勫弬鏁板拰杩斿洖鍊鎬庝箞寮?python鍑芥暟鐨勫弬鏁板拰杩斿洖鍊艰瑙鐧惧害鐭 ...
    绛旓細Python鏄竴闂ㄨ緝涓虹畝鍗曠殑缂栫▼璇█銆2.鐒跺悗鎴戜滑鏉ョ湅涓涓嬬湡棰樿В鏋愶紝鏍规嵁绛旀鏉ヨ繘琛屼簡瑙i鐩В鏋愯繃绋嬨3.鎺ヤ笅鏉ユ垜浠湅涓涓嬪弬鏁板悕澹颁紶閫掞紝python璇█鍚屾椂鏀寔鍑芥暟鎸夌収鍙傛暟鍚嶇О鏂瑰紡浼犻掑弬鏁帮紝璇硶褰㈠紡濡備笅銆4.涓嬩竴涓槸鍑芥暟鐨勮繑鍥炲硷紝return璇彞鐢ㄦ潵缁撴潫鍑芥暟骞跺皢绋嬪簭杩斿洖鍒板嚱鏁拌璋冪敤鐨勪綅缃户缁墽琛屻5.鎴戜滑鐪嬩笅涓涓...
  • python涓,濡傚浘,涓哄暐涓嬮潰鐨return鍚庨潰鐨勮〃杈惧紡鑳界洿鎺ヨ鍙栧閮ㄥ彉閲?鑰屼笂 ...
    绛旓細鈥渪*=x鈥濊繖涓搷浣滅殑闂銆傚湪杩欎箣鍓嶏紝鍑芥暟鍐呴儴娌℃湁瀹氫箟x锛屽洜姝,绛夊彿鍚庨潰鐨剎鏄紩鐢ㄥ閮ㄥ畾涔夌殑f1.x銆傝岀瓑鍙峰乏杈圭殑x锛屽洜涓鸿琚祴鍊硷紝鎵浠ュ畠瑕佷娇鐢╢2鍐呴儴鐨勫彉閲弜锛屼絾杩欎釜x锛坒2.x锛夎繕娌℃湁瀹氫箟锛屽洜姝や笉鑳界敤浜庘*=鈥濇搷浣溿傝屼笅涓娈典腑锛岀洿鎺return x**2,杩欓噷灏辨槸寮曠敤f1.x鑰屼笉闇瑕佽祴鍊硷紝鍥犳灏辨甯...
  • python 濡備綍鑾峰緱杩斿洖鍊 return
    绛旓細瑕佸緱鍒板湪鍒濆鍖栬繃绋嬩腑鐨勮繑鍥炲硷紝鍙互鐢ㄥ彉閲忔妸缁撴灉淇濆瓨璧锋潵锛屾瘮濡傦細class BB():def __init__(self):self.count=0self.result=self.test()def test(self):self.count += 1return str(self.count)鐒跺悗b=BB()鍚庯紝b.result鐨勮繑鍥炲兼槸1.鑷充簬澶氫釜杩斿洖鐨勯棶棰橈紝杩樺ソpython鏄急绫诲瀷鐨勶紝鍙互杩欐牱锛歝lass ...
  • python涓璻eturn鍜寉ield鎬庝箞鐢ㄧ殑?涓や釜鏈変粈涔堝尯鍒?
    绛旓細yield yield鏄敤浜庣敓鎴愬櫒銆備粈涔堟槸鐢熸垚鍣紝浣犲彲浠ラ氫織鐨勮涓猴紝鍦ㄤ竴涓嚱鏁颁腑锛屼娇鐢ㄤ簡yield鏉ヤ唬鏇return鐨勪綅缃殑鍑芥暟锛屽氨鏄敓鎴愬櫒銆傚畠涓嶅悓浜庡嚱鏁扮殑浣跨敤鏂规硶鏄細鍑芥暟浣跨敤return鏉ヨ繘琛岃繑鍥炲硷紝姣忚皟鐢ㄤ竴娆★紝杩斿洖涓涓柊鍔犲伐濂界殑鏁版嵁杩斿洖缁欎綘锛泍ield涓嶅悓锛屽畠浼氬湪璋冪敤鐢熸垚鍣ㄧ殑鏃跺欙紝鎶婃暟鎹敓鎴恛bject锛岀劧鍚庡綋浣犻渶瑕...
  • python鐨剅eturn鍙互杩斿洖澶氫釜鍊煎悧?
    绛旓細渚1銆侊細x闄や互y鐨勪綑鏁颁笌鍟嗙殑鍑芥暟 defF1锛坸锛寉锛夛細a锛漻锛厃 b锛濓紙x锛峚锛夛紡y return锛坅锛宐锛夛純涔熷彲浠ュ啓浣渞eturna锛宐 锛坈锛宒锛夛紳F1锛9锛4锛夛純涔熷彲浠ュ啓浣渃锛宒锛滷1锛9锛4锛塸rintc锛宒 缁撴灉鏄剧ず锛1锛2 Python涓庡ぇ澶氭暟鍏跺畠璇█涓鏍锋湁灞閮ㄥ彉閲忓拰鍏ㄥ眬鍙橀噺涔嬪垎锛屼絾鏄畠娌℃湁鏄庢樉鐨勫彉閲忓0鏄庛傚彉閲...
  • python 鍑芥暟return
    绛旓細鍙互鍙傝python鐢熸垚鍣紝yield鍏抽敭瀛楋紝鍏蜂綋鍙互涓婄綉鎼滄悳銆備笉杩囷紝寤鸿鍙互浣跨敤鍏朵粬鏂规硶鏉ュ畬鎴愯繖涓姛鑳姐傚皢get_info鍑芥暟瀹氫箟涓烘牴鎹畊rl杩斿洖椤甸潰鍐呭锛岀劧鍚庡閮ㄩ氳繃寰幆璋冪敤get_info鏉ュ疄鐜颁綘鎯宠鐨勫姛鑳姐俤ef get_info(url): return urlopen(url).read()if __name__ == '__main__': for url in url...
  • Python璇█鍦ㄥ畾涔夊嚱鏁版椂,return+s,涓殑s鍦ㄥ嚱鏁颁腑鐨勫悕绉版槸?
    绛旓細鍦 Python 璇█涓紝鍑芥暟涓殑 `s` 鏄〃绀轰竴涓簭鍒楋紙Sequence锛夌殑鍙橀噺鍚嶏紝閫氬父鏄竴涓垪琛ㄦ垨鍏冪粍绛夌被鍨嬬殑鏁版嵁闆嗗悎銆傚綋浣跨敤 `return` 鍏抽敭瀛楁椂锛屽皢杩斿洖涓涓寘鍚涓厓绱犵殑搴忓垪銆備緥濡傦細```python def get_numbers():numbers = [1, 2, 3, 4, 5]return numbers num_list = get_numbers()print(num...
  • python threading妯″潡,鐢熸垚澶氱嚎绋涔嬪悗,鎬庝箞寰楀埌绾跨▼鎵ц瀹屾垚鍚return鍑...
    绛旓細浣犲氨蹇呴』绛夊緟杩欎釜鍑芥暟缁撴潫锛屼綘杩欎釜绋嬪簭灏遍樆濉炰簡锛岃繖灏卞け鍘讳簡澶氱嚎绋/澶氳繘绋嬮槻姝㈤樆濉炵殑鎰忎箟浜嗐傞氳鍙互鏄簨浠堕┍鍔ㄦ垨鑰呯敤绾跨▼瀹夊叏鐨勬暟鎹粨鏋勬潵浼犻掓暟鎹紙姣斿Queue锛屼篃鍙互鏄秷鎭槦鍒0mq锛宺abbitMQ涔嬬被锛夛紝鍥炶皟灏辨槸浣犱竴涓▼搴忔墽琛屽畬鎴愬悗璋冪敤鍙﹀涓涓嚱鏁版潵澶勭悊鎺ヤ笅鏉鎬庝箞鍋氥
  • python涓,鎬庝箞璁╃被杩斿洖鍊煎晩?
    绛旓細鍑芥暟鍙互璇存槸涓涓粦绠憋紝杈撳叆涓浜涘硷紝鐒跺悗杈撳嚭涓浜涘硷紝鍥犳return灏辨槸璁╁嚱鏁拌緭鍑哄肩殑鎿嶄綔銆傜劧鑰岋紝绫伙紝绠鍗曟潵璇村氨鏄竴绯诲垪鍑芥暟鐨勯泦鍚堬紝瀹冩渶涓昏鐨勭敤閫旀槸璁惧畾瀵硅薄鍜屾柟娉曘傚湪Python涓锛屾垜绠鍗曚妇涓緥瀛愶紝鎴戣绠梐+b=c锛屾垜杈撳叆a鍜宐锛岃緭鍑篶銆傞偅涔堬紝鍑芥暟灏辨槸杩欐牱鐨勶細def plus(a, b):c = a + b return...
  • python杩斿洖鍊return鑳界粓姝㈠閮ㄥ嚱鏁板悧
    绛旓細鑳姐傚鏋python鐨鏂规硶涓渶鍚庤繑鍥return **,琛ㄧず璇ユ柟娉曞埌姝ょ粨鏉熶笉鍐嶆墽琛,骞惰繑鍥炲搴旂殑鍐呭;濡傛灉鍙湁return琛ㄧず绋嬪簭鍒版涓,涓嶅啀鎵ц,鐩稿綋浜庢墦鏂偣銆傛湜閲囩撼,璋㈣阿銆
  • 扩展阅读:return result python ... python func ... for i in range函数 ... python中returns1 e1 ... unexpected indent ... return can be used only ... return outside function ... while true learn ... python return函数用法 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网