如何将元组数据提取为单元素格式 [英] How To Extract Tuple Data into Single Element Format

查看:23
本文介绍了如何将元组数据提取为单元素格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从以下内容中得到了不错的结果,但是如何从元组中提取该数据?换句话说,我如何清理数据?

这里是数据库的数据,我用完了.

<预><代码>>>>policy_id = ((2309L,), (118L,), (94L,))>>>对于 policy_id 中的 i:打印我(2309L,)(118L,)(94L,)

但我希望结果为:

230911894

解决方案

policy_id = ((2309L,), (118L,), (94L,))对于 policy_id 中的 i:打印 i[0]

I get back good results from the following, but how to I extract that data from the tuple? In other words, how do I clean up the data?

Here is the data from the database, I ran out.

>>> policy_id = ((2309L,), (118L,), (94L,))
>>> for i in policy_id:
        print i


(2309L,)
(118L,)
(94L,)

But I want the result as:

2309
118
94

解决方案

policy_id = ((2309L,), (118L,), (94L,))
for i in policy_id:
    print i[0]  

这篇关于如何将元组数据提取为单元素格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆