概述
运行以下脚本又遭遇 EOL while scanning string literal问题
#coding=utf-8
import arcpy
import os
import os.path
inWorkspace = arcpy.GetParameterAsText(0) #输入英文城市名文件所在路径,下含已转好的DAE_SHP文件夹 D:
#inWorkspace = "D:\PythonCode_inWork\09DAE_SHP_Check\PROCESS\DATA\YANGZHOU"
#arcpy.AddMessage(inWorkspace)
#城市名自动获取
city = os.path.split(inWorkspace)[-1]
###_H合并Tile
##shps_dir = inWorkspace + "\DAE_SHP"
##shps = os.listdir(shps_dir)
##shps_H = []
##for i in shps:
## if '_H_poly.shp' in i:
## shps_H.append(shps_dir+"\"+i)
##arcpy.AddMessage('Start merging...')
###merge_name = city + "_MERGE.shp"
###merge_result = os.path.join(inWorkspace,merge_name)
##merge_result = inWorkspace + "\" + city + "_MERGE.shp"
###print merge_result
##arcpy.Merge_management(shps_H, merge_result)
##arcpy.AddMessage('Merging succeed!')
##
###按PID融合
##arcpy.AddMessage('Start dissolving...')
dissolve_result = inWorkspace + "\" + city + "_DISSOLVE.shp"
##arcpy.Dissolve_management(merge_result, dissolve_result, ["PID", "FTYPE"])
##arcpy.AddMessage('Dissolving succeed!')
#与Tile面交集取反
Outline = ""
arcpy.AddMessage('Start symdiffing...')
for j in os.listdir(inWorkspace):
#城市分tile匹配,如Suzhou_19Q3_Submit_Grid_M_01.shp
if ("Submit_Grid_M" in j) and (".shp" in j) and (j.count(".")==1):
Outline = j
inFeatures = inWorkspace + "\" + Outline
updateFeatures = dissolve_result
outFeatureClass = inWorkspace + "\" + city + "_SymDiff.shp"
arcpy.SymDiff_analysis(inFeatures, updateFeatures, outFeatureClass, "ALL", 0.05)
arcpy.AddMessage('Symdiffing succeed!')
#拆分多部件要素
blue = inWorkspace + "\" + city + "_BLUE.shp"
arcpy.MultipartToSinglepart_management(outFeatureClass, blue)
#漏蓝检查提示消息
feature_count = int(arcpy.GetCount_management(blue).getOutput(0))
if feature_count == 0:
arcpy.AddMessage("No Blue!Congratulations!".format(feature_count))
elif feature_count == 1:
arcpy.AddMessage("There is {0} blue gap to confirm!".format(feature_count))
else:
arcpy.AddMessage("There are {0} blue gaps to confirm!".format(feature_count))
重点是:
此脚本之前已经解决了EOL while scanning string literal问题
方法:路径里最后一个"/"必须写成“\”,写成"/"或r“”都不行,虽然语法上都正确。
详见博客https://blog.csdn.net/lzqg1990/article/details/89554069
与之前正常运行的脚本相比,仅注释掉了无用的部分代码,修改了如下的if条件。
所以本不应再出现EOL while scanning string literal问题。
后为分析路径中斜杠,增加了一行代码,打印inworkspace路径字符串:
结果问题就奇迹般的消失了,未解之谜。
后来呢,我又需要将注释掉的代码用回来
结果取消注释后,又EOL while scanning string literal
有种直觉让我把这句又注释掉:
奇迹又出现了!成功运行!
我大概领悟了
改存1次之后
EOL while scanning string literal会自动消失...
最后
以上就是老实金鱼为你收集整理的EOL while scanning string literal问题之谜的全部内容,希望文章能够帮你解决EOL while scanning string literal问题之谜所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复