gpt4 book ai didi

android - Python 引发 SyntaxError

转载 作者:行者123 更新时间:2023-11-29 17:58:47 27 4
gpt4 key购买 nike

我正在为 Android 下的特定平板电脑克隆一个存储库并获取源代码,我必须执行一个 python 脚本。当我执行它时,我收到此错误消息:

Traceback (most recent call last):
File "/home/user/android-imx-sources/.repo/repo/main.py", line 40, in <module>
from subcmds.version import Version
File "/home/user/android-imx-sources/.repo/repo/subcmds/__init__.py", line 41
raise SyntaxError, '%s/%s does not define class %s' % (
^
SyntaxError: invalid syntax

脚本的完整代码:


import os

all_commands = {}

my_dir = os.path.dirname(__file__)
for py in os.listdir(my_dir):
if py == '__init__.py':
continue

if py.endswith('.py'):
name = py[:-3]

clsn = name.capitalize()
while clsn.find('_') > 0:
h = clsn.index('_')
clsn = clsn[0:h] + clsn[h + 1:].capitalize()

mod = __import__(__name__,
globals(),
locals(),
['%s' % name])
mod = getattr(mod, name)
try:
cmd = getattr(mod, clsn)()
except AttributeError:
raise SyntaxError, '%s/%s does not define class %s' % (
__name__, py, clsn)

name = name.replace('_', '-')
cmd.NAME = name
all_commands[name] = cmd

if 'help' in all_commands:
all_commands['help'].commands = all_commands

最佳答案

应该是:

raise SyntaxError('%s/%s does not define class %s' % (__name__, py, clsn))

关于android - Python 引发 SyntaxError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17378727/

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