import sys
try:
file = open("words.txt")
expect(IOError):
if file:
print "%s" % file
else:
print "Cant the %s file" % "words.txt"
这给了我一个错误 -
File "main.py", line 4
expect(IOError):
SyntaxError: invaild syntax
我出了什么问题/你如何解决这个问题
请您参考如下方法:
实际上,它是异常的:
例如:
except IOError:
print "Error opening file!"
