SQL Alchemy 返回类型

编程入门 行业动态 更新时间:2024-10-23 13:37:31
本文介绍了SQL Alchemy 返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 session.query().filter 查询表.我得到如下输出:(u'1234').但是当我尝试使用 str.translate(None, '5) 翻译它时,它会引发错误

I am querying the table using session.query().filter. I get an output like: (u'1234'). But when I try to translate this using str.translate(None, '5), it throws an error

KeyedTuple' object has no attribute 'translate'

我哪里出错了?

推荐答案

你得到一个包含一个元素的元组.在对它使用 result_string.translate 之前,您必须先检索这个元素.

You get a tuple with one element. You have to retrieve this one element first before using result_string.translate on it.

如果您将 session.query().filter 的返回值保存在变量 result 中,请执行

If you save the return of your session.query().filter inside a variable result do

if result: # Check that result is not empty result[0].translate(...)

更多推荐

SQL Alchemy 返回类型

本文发布于:2023-10-16 11:58:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   SQL   Alchemy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!