gpt4 book ai didi

python - 如何忽略 - 错误 : The system was unable to find the specified registry key or value

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:49 25 4
gpt4 key购买 nike

def isAlreadyInstalled(lookupRegistryKey):
consoleLines = os.popen('reg query "' + APP_REGISTRY_KEY + "\\" + VERSION_SYSTEM_NAME + '"').readlines()
if len(consoleLines) == 0:
return False
return True

所以我创建了这个方法,但问题是,当我执行脚本时,在命令行中出现此错误:

ERROR: The system was unable to find the specified registry key or value.

我还没能忽略它。如何忽略执行期间命令行中显示的此错误?

最佳答案

所以你希望这个函数根据if len(consoleLines) == 0:返回TrueFalse,否则只返回控制回来,可以这样做

def isAlreadyInstalled(lookupRegistryKey):
try:
consoleLines = os.popen('reg query "' + APP_REGISTRY_KEY + "\\" + VERSION_SYSTEM_NAME + '"').readlines()
if len(consoleLines) == 0:
return False
return True
except:
return

关于python - 如何忽略 - 错误 : The system was unable to find the specified registry key or value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54475788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com