import MySQLdb
db = MySQLdb.connect("localhost","root","password","database")
cursor = db.cursor()
cursor.execute("SELECT id FROM some_table")
u_data = cursor.fetchall()
>>> print u_data
((1320088L,),)
我在互联网上找到的内容让我走到了这里:
string = ((1320088L,),)
string = ','.join(map(str, string))
>>> print string
(1320088L,)
我期望的输出结果是什么:
#Single element expected result
1320088L
#comma separated list if more than 2 elements, below is an example
1320088L,1320089L