首页 > 解决方案 > Python try except: InvalidSyntax

问题描述

I'm trying the Designer GUI TOOL of pyFpdf but upon running the designer.py with python designer.py it gives an error:

  File "designer.py", line 154
    except Exception, e:
                    ^
SyntaxError: invalid syntax

I checked the python file at line 154 and it's this code:

try:
    values[field] = eval(dlg.textctrls[field].GetValue())
except Exception, e:
    msg = wx.MessageDialog(parent, unicode(e),
           "Error in field %s" % field,
            wx.OK | wx.ICON_INFORMATION
            )
    msg.ShowModal()
    msg.Destroy()
    break

Is it the pyfpdf's problem? I'm running Python 3.8

标签: pythonpython-3.xfpdfpyfpdf

解决方案


Yes, it's pyfpdf's problem. This is Python2 syntax. There should be a newer version on the project site which is written for Python3. They also describe the problem here.


推荐阅读