小编Jue*_*Kim的帖子

如何在python上将元组类型转换为int?

我是pyhton初学者.我想将sqlcommand结果(元组类型)转换为int类型.我怎样才能做到这一点?

import MySQLdb

db = MySQLdb.connect("localhost","root","password","database")
cursor = db.cursor()
cursor.execute("SELECT timestamp FROM unixdb")
u_data = cursor.fetchall()

>>> print u_data
((1424794931452.0,),)
Run Code Online (Sandbox Code Playgroud)

u_data类型是元组,我想得到u_data的int类型.

python int tuples type-conversion

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

int ×1

python ×1

tuples ×1

type-conversion ×1