我正在使用Java2Python包将Java项目转换为Python,但出现错误。

[root@localhost Desktop]# j2py ConfigurationManager.java ConfigurationManager.py
      File "/usr/bin/j2py", line 113
        except (IOError, ), exc:
                          ^
    SyntaxError: invalid syntax

File /usr/bin/j2py, line 113

try:
    if filein != '-':
        source = open(filein).read()
    else:
        source = sys.stdin.read()
except (IOError, ), exc:
    code, msg = exc.args[0:2]
    print 'IOError: %s.' % (msg, )
    return code


如果需要任何信息,请告诉我。



更新

 File "/usr/bin/j2py", line 115
    print 'IOError: %s.' % (msg, )
                       ^
SyntaxError: invalid syntax

最佳答案

尝试这个 :

except (IOError) as exc:
        for arg in exc.args:
           print(str(arg))
        code = exc.args[0]
        return code


在这里,我假设您要在exc.args中返回第一个值

关于java - 使用Java2Python从Java到Python,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50369095/

10-09 01:28