我有一个带有嵌套for
循环的 python 脚本
HostList = file('trylist.txt')
DestHostList = file('trylist2.txt')
for DestHost in DestHostList:
DestHost = DestHost.strip()
for HostName in HostList:
HostName = HostName.strip()
try:
if DestHost!=HostName:
print HostName,DestHost
print "one loop finishes"
except Exception, e:
ExceptionHost.write(HostName+' - '+DestHost+': '+str(e)+'\n')
print "exception"
#traceback.print_exc(file=sys.stdout)
外部for
循环似乎只执行一次。潜在的问题是什么?