引发KeyError
不会格式化字符串而其他错误的原因是什么? (注意嵌入的\n
vs下面示例中的新行)
In [1]: raise KeyError("Does not \n format")
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-1-2a34667e842b> in <module>()
----> 1 raise KeyError("Does not \n format")
KeyError: 'Does not \n format'
而ValueError
In [2]: raise ValueError("Does \n format")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-3f8ba28869e2> in <module>()
----> 1 raise ValueError("Does \n format")
ValueError: Does
format
或IndexError
In [3]: raise IndexError("Does \n format")
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-4-2db4e87594fd> in <module>()
----> 1 raise IndexError("Does \n format")
IndexError: Does
format