我正在从<代码>测试.xls文档中处理数据读物,如:
from sys import exe_info
try:
book = xlrd.open_workbook( test.xls )
sh = book.sheet_by_index(0)
for row in range( 1, sh.nrows ):
for index, value in enumerate(sh.row_values(row)):
process_value(value)
except:
print exc_info()[1]
如果在处理<代码>过程中出现例外情形——价值(价值)代码>,则该条目中有一些错误。 但在印刷<代码>exc_info( ) ***时。 我得以接受例外描述,如:
ascii codec can t encode characters in position 7-10: ordinal not in range(128)
但是,如果我印刷<代码>exc_info(>功能,则按产出提供。
(<type exceptions.UnicodeEncodeError >, UnicodeEncodeError( ascii , u bokor bxe3u0192xe2xa9la , 7, 11, ordinal not in
range(128) ), <traceback object at 0x01067080>)
因此,如果我想对用户作例外处理,那么用户就会在<条码>的某一行文上受到质疑,该编码表示出错误。 因此,在<代码>exc_info(>上。 我可以看到这个词。
u bokor bxe3u0192xe2xa9la
This is the word from XLS file. If we can t show for which line error is raise if I at lease show that above word it will help to find that word and remove that word.
I am not able to get that particular word from exc_info()
or is their is any better way to handle this situation?