單項(xiàng)選擇題在Python中,如何創(chuàng)建一個(gè)生成器函數(shù)?()

A.def func():yield x
B.function*func(){yield x;}
C.generator func(){yield x;}
D.func =generator(x for x in range(10))


您可能感興趣的試卷

你可能感興趣的試題

1.單項(xiàng)選擇題在Python中,如何使用條件表達(dá)式(三元運(yùn)算符)?()

A.x if condition else y
B.condition ?x :y
C.if condition:x else:y
D.condition then x else y

2.單項(xiàng)選擇題在Python中,如何檢查一個(gè)文件是否存在?()

A.os.path.exists(path)
B.file.exists(path)
C.path.exists(file)
D.os.exists(file)

3.單項(xiàng)選擇題在Python中,如何判斷一個(gè)字符串是否以某個(gè)子字符串結(jié)束?()

A.str.endswith(substring)
B.endswith(str,substring)
C.str.hasSuffix(substring)

4.單項(xiàng)選擇題在Python中,如何判斷一個(gè)字符串是否以某個(gè)子字符串開始?()

A.str.startswith(substring)
B.str.beginswith(substring)
C.str.hasPrefix(substring)
D.startswith(str,substring)

5.單項(xiàng)選擇題在Python中,如何測(cè)試一個(gè)條件,并根據(jù)結(jié)果執(zhí)行不同的代碼塊?()

A.if condition:pass else:pass
B.test condition then pass else pass
C.if condition:pass elseif:pass
D.condition ?pass :pass