Q:

Why is the format of the string different for each output? - Python,mariaDB

Connecting to the database and printing the version information.
db = pymysql.connect(host='localhost', port=3306, user='root',
     passwd='root', db='exam',charset='utf8')
cursor = db.cursor()
cursor.execute("select version()")
data = cursor.fetchone()

print "version : %s" % data
print "%s" % data
print data

The result of the first print (print "version : %s" % data)

version : 5.5.56-MariaDB

The result of the second print (print "%s" % data)

5.5.56-MariaDB

The result of the third print (print data)

(u'5.5.56-MariaDB',)

Why is the output string different?
i don't know why looks like the third result.
Is there any way to get output like the second output when printing with the third print result?
thanks.

A:

data is a 1-tuple (because fetching query results like that results in a tuple), and string interpolation takes a tuple as the RH operand.
print data[0]

