简体   繁体   中英

how to store tuple value as python variable

I am fetching mysql select statement as a tuple. How do I extract 0 or 1 from the 2nd value? Here is the code.

records = cursor.fetchall()
print(records)
('billtest1407337726531', '\x00')
records1 = curson.fetchall()
print(records1)
('billtest1407337726531', '\x01')

I need to store the value 0 or 1 from above tuples records and records1

I tried as below but it isn't working.

for row in records
   print(row[1])
   print((tuple(row[1:1]))

您希望ord(records[1])获取第二个值并将其从字符串转换为整数(不是解析,只是转换字节)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM