Python 3.4.1 脚本语法错误,arcpy & [英] Python 3.4.1 script syntax error, arcpy &

查看:61
本文介绍了Python 3.4.1 脚本语法错误,arcpy &的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯于在 python 2.7 中工作,所以有一些新东西,比如打印功能不同.所以请原谅我的无知.我对编程也很陌生.

I am used to working in python 2.7 so there was some new things like the print function being different. So excuse my ignorance. I am also pretty new to programming.

这是我的脚本,我不断收到错误,突出显示一些逗号或空格并说有一个

So here is my script, I keep getting errors that highlight some commas or spaces and saying there is a

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: malformed \N character escape

代码:

import arcpy

print("mosaic to new raster starting!")

env.workspace = "F:\GDAL"
arcpy.env.pyramid = "NONE"
arcpy.env.rasterStatistics = "NONE"
arcpy.env.compression = "JPEG 87"
arcpy.env.tileSize = "256 256"

print("Environment set")

RasterInput = "m_3511401_ne_11_1_20130731.jpg;m_3511401_nw_11_1_20130731.jpg;m_3511401_se_11_1_20130731.jpg;m_3511401_sw_11_1_20130731.jpg;"

print("Input set")

arcpy.MosaicToNewRaster_management(RasterInput,"F:\Pro_Projects\NAIP2013\raster.sde","MosaicFile1","","8_BIT_UNSIGNED","","3","LAST","FIRST")

print("mosaic done!")

推荐答案

反斜杠(您用作 Windows 路径分隔符)表示 Python 字符串中的转义序列.双反斜杠或使用原始字符串文字:

Backslashes (used by you as Windows path separators) signal escape sequences in Python strings. Double the backslashes or use a raw string literal:

"F:\\Pro_Projects\\NAIP2013\\raster.sde"

r"F:\Pro_Projects\NAIP2013\raster.sde"

Windows 还接受路径中的正斜杠,完全避免了这个问题:

Windows also accepts forward slashes in paths, avoiding the issue altogether:

"F:/Pro_Projects/NAIP2013/raster.sde"

这篇关于Python 3.4.1 脚本语法错误,arcpy &的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆