求教python实现grid格式批量转换为tif格式时,代码出错

本人小白,网上看到一段代码,使用python脚本来实现批量转换,把f:\\test文件夹下的*.grd栅格文件转换为*.TIFF文件并存于其下的TIFF子文件夹中:

捕1.PNG

但是运行时候报错:

捕获2.PNG

我发现倒数第4行复制过来多了个?,
arcpy.RasterToOtherFormat_conversion(Input_raster_file,?
...                         Output_Workspace, Raster_Format)
 
 
我试了几次,怎么改都不行,求教各位,这段代码应该怎么改呀?
已邀请:

江宝骅

赞同来自: mushaojie

360截图20161206141002761.jpg

应该是换行造成的,将21行22行替换为下方
arcpy.RasterToOtherFormat_conversion(Input_raster_file, Output_Workspace, Raster_Format)

mushaojie

赞同来自:

# Import system modules
import sys, string, os

dir = 'F:\\test'

# Import arcpy module
import arcpy

files = os.listdir(dir)
for f in files:
    if os.path.splitext(f)[1] == '.grd':
        # Script arguments...
        Input_raster_file = dir + os.sep + f

        # Local variables...
        Output_data_type = "FLOAT"
        Raster_Format = "TIFF"
        Output_Workspace = "f:\\test\\TIFF"

        # =============== file name process ======================
        basename = os.path.splitext(f)[0];
        Output_raster = Output_Workspace + os.sep + basename + ".tif";

        if os.path.exists(Output_raster) == False:
            print Input_raster_file
            # Process: Raster To Other Format (multiple)...
            arcpy.RasterToOtherFormat_conversion(Input_raster_file, 
                        Output_Workspace, Raster_Format)

            print Output_raster

要回复问题请先登录注册