我正在从控制台运行一些 python 代码(粘贴),并得到意外的结果。代码如下所示:
parentfound = False
structfound = False
instruct = False
wordlist = []
fileHandle = open('cont.h')
for line in fileHandle:
if line is "":
print "skipping blank line"
continue
if "}" in line:
instruct = False
index = line.index("}")
wordlist.append(word)
pass
try:
print wordlist
except Exception as e:
print str(e)
在 for 循环之后,我想打印wordlist
。无论我做什么,我都不能在 for 循环之外包含任何内容。这是我收到的错误:
... if "}" in line:
... instruct = False
... index = line.index("}")
... wordlist.append(word)
... pass
... try:
File "<stdin>", line 10
try:
^
SyntaxError: invalid syntax
无论我是在终端中手动输入代码还是将代码粘贴到终端中,都会发生这种情况。我将不胜感激您提供的任何帮助。谢谢你!
The ...
prompt in the REPL means that it still hasn't finished the previous block. You will need to press Enter on an empty line to terminate it first.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)