我正在计算文件"Index40"中的行数.有11,436行.我将该数字保存在txt文件中作为字符串.我希望我的代码要做的是每晚计算此文件中的行数,如果等于存储为单个字符串值的数字,我希望脚本结束,否则重写文本文件中的数字并继续剧本.我遇到的问题是脚本总是认为行计数不等于txt值.这是代码:
lyrfile = r"C:\Hubble\Cimage_Project\MapData.gdb\Index40"
result = int(arcpy.GetCount_management(lyrfile).getOutput(0))
textResult = str(result)
with open(r'C:\Hubble\Cimage_Project\Index40Count.txt', 'r+') as a:
if a == textResult:
pass
else:
a.write(textResult)
#then do a bunch more code
print "not passing"
Run Code Online (Sandbox Code Playgroud)