1
這是this post的後續處理。重申一下,我有一個帶有給定位置的元數據和測量數據的文本文件。我想將這些數據寫入名爲ArcGIS的空間映射軟件,爲此我必須爲列表中的每個值指定數據類型,如ArcGIS中所定義。例如:使用字典將python數據類型轉換爲其他語言的數據類型
type("foo")
給出在Python str
,但已知,在ArcGIS text
。所以,我想將我列表中每個元素的數據類型轉換爲ArcGIS中相應的數據類型。事情是這樣的:
# This is the raw data that I want to write to ArcGIS
foo= ['plot001', '01-01-2013', 'XX', '10', '12.5', '0.65', 'A']
# The appropriate datatypes in Python are:
dt= [str, str, str, int, float, float, str]
# In ArcGIS, the datatypes should be:
dtArcGIS= ['text', 'text', 'text', 'short', 'float', 'float', 'text']
的問題是:我怎麼可以來自dt
到dtArcGIS
?我在想dictionary
爲:
dtDict= dict{str:'text', int:'short', float:'float'}
但是這給出了語法錯誤。任何幫助將不勝感激,謝謝!
刪除' dict',大括號已經將它定義爲字典,沒有nee d告訴Python再次執行,'dtDict = {str:'text',int:'short',float:'float'}' – Ben
'type('10')''是'str',而不是'int' – alko
謝謝指出! – HDR