Python IF语句上的InvalidSyntax

Python IF语句上的InvalidSyntax,python,if-statement,syntax,Python,If Statement,Syntax,我不知道下面出了什么问题。。。继续获取IF语句的语法错误 #Specify a key file keyfile="C:\Python27/keepasskey" try: debug = Debug() if os.path.isfile(keyfile): print "[+] Keyfile Loaded: '" + keyfile + "'" aProcess = debug.execv(['KeePass.exe', 'Database.kdb', '-keyfile:' +

我不知道下面出了什么问题。。。继续获取IF语句的语法错误

#Specify a key file
keyfile="C:\Python27/keepasskey"

try:
 debug = Debug()

if os.path.isfile(keyfile):
 print "[+] Keyfile Loaded: '" + keyfile + "'"
 aProcess = debug.execv(['KeePass.exe', 'Database.kdb', '-keyfile:' + keyfile, '-pw:'.ljust(WORD_SIZE+4)])
else:
    print "[+] Specified keyfile '" + keyfile + "' does not exist, ignoring argument"
    aProcess = debug.execv( ['KeePass.exe', 'Database.kdb', '-pw:'.ljust(WORD_SIZE+4)])

提前谢谢

您需要缩进您的
if
语句,以便它可能在
try
语句的范围内,或者您需要在
中加入一个
,除了
try
之后,但在
if
之前。像这样:

try:
  debug = Debug()
  if os.path.isfile(keyfile):
    print "Indentation is required and part of the language syntax"

您的
尝试
需要一个
,除了
。另外,你应该使你的缩进在整个模块中保持一致。谢谢,这很有效,但现在我面临一个不同的问题。这是我在运行代码文件“C:\Python27\lib\site packages\winappdbg\win32\defines.py”时尝试运行的完整代码[link],位于RaiseIfZero raise ctypes.WinError()WindowsError:[错误2]找不到指定的文件。
@user3534160打开一个新问题,询问您正在使用的代码和看到的异常,让我们看看是否无法修复。谢谢。我提出了一个新问题: