我正在学习python。它在此脚本中给出了语法错误。我无法弄清楚。Python中的语法错误:
import exceptions
class FOUND(Exception): pass
x = [1,2,3,4,56,73,29,35,12,32,63,12,76,75,89]
while True:
try:
test = int(raw_input('Enter integer to be checked in list:'))
count = -1
for y in x:
count += 1
if y == test:
raise FOUND
except ValueError as e:
print "Not a valid integer (%s)"%(e)
except FOUND:
print "Found (%d) at (%d)"%(test,count)
else:
print "Not found ,Appending (%d) to list at location (%d)"%(test,count+1)
x.append(test)
finally:
print "The List:"
print x
print " "
无效的语法&它强调在这一行右双引号:print "Not a valid integer (%s)"%(e)
什么是错误? – Salil 2010-06-14 12:02:08
您正在使用python-2.x代码和py3k解释器。而且,改变这样的问题使得已经回答的人看起来像完全白痴。 – SilentGhost 2010-06-14 12:15:18
我正在使用py3k解释器 – pecker 2010-06-14 12:16:21