單項選擇題在Python中,如何創(chuàng)建一個自定義異常?()

A.class MyException(Exception):pass
B.create Exception(’MyException’)
C.exception MyException
D.new Exception(’MyException’)


您可能感興趣的試卷

你可能感興趣的試題

1.單項選擇題在Python中,如何使用正則表達式匹配一個字符串?()

A.re.match(pattern,string)
B.string.match(pattern)
C.pattern.match(string)
D.regex.match(string,pattern)

2.單項選擇題在Python中,如何從字典中獲取一個值,如果鍵不存在則返回默認(rèn)值?()

A.dict.get(key,default)
B.dict[key]or default
C.dict.getValue(key,default)
D.dict.fetch(key,default)

3.單項選擇題在Python中,如何將多個字符串連接成一個字符串?()

A.’’.join(list)
B.str.concat(list)
C.’+’.join(list)
D.list.join()

4.單項選擇題在Python中,如何創(chuàng)建一個集合?()

A.set ={}
B.set =set()
C.set =[]
D.set =newArray()

5.單項選擇題在Python中,如何創(chuàng)建一個列表?()

A.list =[]
B.list =list()
C.list =array()
D.list =newArray()