python - 并非所有参数都在字符串格式化期间转换(Flask、ImageMagick 和 SQLAlchemy_ImageAttach)
问题描述
我真的无法理解这个错误。当我尝试对 user.picture 进行更改时,它会发送写在标题中的错误。我无法找到任何其他与此相关的错误发生的示例。
这是错误:
not all arguments converted during string formatting on line 429
第 429 行如下所示:
db.session.commit()
这是我的商店:
store = FileSystemStore(
path='bin/static/img',
base_url='/'
)
如果我改用这样的商店,我会得到同样的错误:
store = HttpExposedFileSystemStore(
path='bin/static/img/',
prefix='static/img/'
)
这是我尝试提交给定图片的示例
with store_context(main.AppClass.store):
current_user.picture.from_file(_profile_picture)
db.session.commit()
这是我尝试对二进制执行相同操作的示例
with store_context(main.AppClass.store):
byte_str = base64.b64encode(_profile_picture.read())
decoded_byte_str = base64.b64decode(byte_str)
current_user.picture.from_blob(decoded_byte_str)
db.session.commit()
他们都给了我同样的错误,这让我相信我的商店可能有问题,但我无法真正开始理解如何。
但是,如果我做这样的事情作为测试,看看它是否有效:
with store_context(main.AppClass.store):
current_user.set_name("asd")
db.session.commit()
它毫无问题地提交。我在这里有点不知所措,不胜感激。
解决方案
推荐阅读
- c - libvlc 获取媒体类型(音频或视频)
- php - 如何在 custom_loader 中加载库?
- vsto - 有没有办法将 VSTO 加载项嵌入到文档中?
- angular - Webpack Bundle Analyzer 给出错误 EACCES
- reactjs - 单击一个子组件隐藏所有其他相同的子组件
- python - 获取对调用函数的类实例的引用
- python - 如何从节点 js 关闭特定的 python 子进程和特定的 selenium webdriver 窗口
- swift - 如何使用 SwiftUI 视图代替表格视图单元格
- flutter - 查询当前 Flutter AppLifecycleState
- r - 生成引用现有变量的动态变量