PythonIf州的无效语法

2024-05-28 20:39:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道下面怎么了。。。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)])

提前谢谢!你知道吗


Tags: debugsizeif语句exedatabasewordprint
1条回答
网友
1楼 · 发布于 2024-05-28 20:39:36

您需要缩进您的if语句,以便它可能在try语句的范围内,或者您需要将except放在try之后if之前。像这样:

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

相关问题 更多 >

    热门问题