單項(xiàng)選擇題在Python中,如何寫入一個文件?()

A.with open(file,’w’)as f:f write(content)
B.file.write(content)
C.open(file,’w’).write(content)
D.A和C都對


您可能感興趣的試卷

你可能感興趣的試題

1.單項(xiàng)選擇題在Python中,如何讀取一個文件的內(nèi)容?()

A.with open(file,’r’)as f:content =f read()
B.file.read()
C.open(file,’r’).read()
D.A和C都對

2.單項(xiàng)選擇題在Python中,如何檢查一個變量是否為None?()

A.variable is None
B.variable ==None
C.variable ===None
D.A和B都對

3.單項(xiàng)選擇題在Python中,如何使用裝飾器?()

A.@decorator def func():pass
B.def func()decorator:pass
C.func =decorator(func)
D.A和C都對

4.單項(xiàng)選擇題在Python中,如何創(chuàng)建一個生成器函數(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))

5.單項(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