arcmap會自動生成乙個objectid欄位,在將最終的excel輸出上載到.dtt檔案之前,我需要刪除該欄位,該檔案中已指定陣列且無法更改。因此,指令碼必須開啟並讀取使用arcpy建立的excel檔案,將所有資料複製到dict(不包括第0列),然後使用xlwt將dict寫入新工作簿。在克服了無數的障礙之後,除了xlwt在將dict寫入新的xls檔案時遇到意外的資料型別外,我什麼都做了:traceback (most recent call last):
file "c:\python27\arcgis10.2\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 323, in runscript
debugger.run(codeobject, __main__.__dict__, start_stepping=0)
file "c:\python27\arcgis10.2\lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run
_getcurrentdebugger().run(cmd, globals,locals, start_stepping)
file "c:\python27\arcgis10.2\lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 654, in run
exec cmd in globals, locals
file "n:\python\completed scripts\recol1_svrsta00_prep2.py", line 2, in
import arcpy, xlrd, xlwt
file "c:\python27\arcgis10.2\lib\site-packages\xlwt\worksheet.py", line 1030, in write
self.row(r).write(c, label, style)
file "c:\python27\arcgis10.2\lib\site-packages\xlwt\row.py", line 257, in write
self.__rich_text_helper(col, label, style, style_index)
file "c:\python27\arcgis10.2\lib\site-packages\xlwt\row.py", line 283, in __rich_text_helper
raise exception ("unexpected data type %r" % type(data))
exception: unexpected data type
我想知道是否可以使用try和except來克服這個問題,但我不確定如何編寫except語句。否則,有沒有其他方法可以克服最後乙個錯誤?以下是減去所有arcpy內容(工作正常)和import module語句的指令碼:
^$
python異常類 python 異常型別
1 nameerror 嘗試訪問乙個未申明的變數 v nameerror name v is not defined 2 zerodivisionerror 除數為0 v 1 0 zerodivisionerror int division or modulo by zero 3 syntaxerr...
Python異常處理和異常型別
try some functions.except exception,e print e try some functions.except exception as e print e 注意這裡exception,e變成了exception as e 1.nameerror 嘗試訪問乙個未申明的...
python異常型別列表
1.nameerror 嘗試訪問乙個未申明的變數 v nameerror name v is not defined2.zerodivisionerror 除數為0 v 1 0 zerodivisionerror int division or modulo by zero3.syntaxerror...