python - 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
解决方案
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.
推荐阅读
- python - 如何解码从 Python 文件中读取的 unicode 字符串?
- bash - 通过类型修改将一个 csv 标头复制到另一个 csv
- python - 如何使用python的“列表”添加新列并找到元素之间的对应关系?
- python-3.x - PyInstaller .exe 因 console=false 而失败,但与 console=true 一起工作
- c++ - C++ SFML。如何创建一个缩小(缩小)的圆圈
- java - 为什么 PDFBox 读取图像宽度/高度错误?(总是假设“宽度”是较大的)
- python - 测试目录中的相对导入
- ruby-on-rails - Rails 应用程序 Stripe 付款在生产中不起作用
- reactjs - React 无法弄清楚为什么我会收到太多重新渲染错误
- scapy - 如何使用 scapy 发送命令?