单项选择题
在Python中,如何创建一个自定义异常?()
A.class MyException(Exception):pass
B.create Exception(’MyException’)
C.exception MyException
D.new Exception(’MyException’)
点击查看答案&解析
相关考题
-
单项选择题
在Python中,如何使用正则表达式匹配一个字符串?()
A.re.match(pattern,string)
B.string.match(pattern)
C.pattern.match(string)
D.regex.match(string,pattern) -
单项选择题
在Python中,如何从字典中获取一个值,如果键不存在则返回默认值?()
A.dict.get(key,default)
B.dict[key]or default
C.dict.getValue(key,default)
D.dict.fetch(key,default) -
单项选择题
在Python中,如何将多个字符串连接成一个字符串?()
A.’’.join(list)
B.str.concat(list)
C.’+’.join(list)
D.list.join()
