Python2.x中抛出Unicode的异常需要注意:
| 1 2 3 4 5 |  | 
会报UnicodeEncodeError: ‘ascii’ codec can’t encode character …
同样,如果在log中直接输出,也会报错
| 1 2 3 4 5 6 7 8 |  | 
简单的解决办法就是用e.message
| 1 2 3 4 5 |  | 
也可以详细的可以指定encoder
| 1 2 3 4 |  | 
Python3就没这个事了,备忘一下。
参考:
http://bugs.python.org/issue2517
Python2.x中抛出Unicode的异常需要注意:
| 1 2 3 4 5 |  | 
会报UnicodeEncodeError: ‘ascii’ codec can’t encode character …
同样,如果在log中直接输出,也会报错
| 1 2 3 4 5 6 7 8 |  | 
简单的解决办法就是用e.message
| 1 2 3 4 5 |  | 
也可以详细的可以指定encoder
| 1 2 3 4 |  | 
Python3就没这个事了,备忘一下。
参考:
http://bugs.python.org/issue2517