简体   繁体   中英

How to convert this tuple to array python

This one outputs tuple, but I want it to convert to array so I can access each element in the array to my main function. here is the code:

def numbers():
    db = getDB();
    cur = db.cursor()
    sql = "SELECT mobile_number FROM names"
    cur.execute(sql)
    result = cur.fetchall()

    for [x] in result:
        print(x)

解决方法很简单:

result = list(cur.fetchall())

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