我只想打印不带任何括号、逗号或圆括号的值。我正在使用 MySQL 和 python 以及 mysql.connector。
当我运行此代码时,我得到“('esrvgf',)”。但我只想得到“esrvg”。
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", password="password", database ="mydatabase" ) cursor = mydb.cursor() sql = "select nick from users where ipaddress = '192.168.1.4'" cursor.execute(sql) myresult = cursor.fetchall() for x in myresult: print(x)
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号