# -*- coding: utf-8 -*-
import os
import time
import re
import urllib
import urllib2
import MySQLdb
hostip = raw_input("Input your sql Ip:")
username = raw_input("Input your sql username:")
password = raw_input("Input your password:")
dbname = raw_input("Input your dbname :")
conn = MySQLdb.connect(host = hostip, user = username, passwd = password, db = dbname)
cur = conn.cursor()
cur.execute("show tables")
alltable = cur.fetchall()
tablenames = []
for i in range(len(alltable)):
for j in range(len(alltable[i])):
tablenames.append(alltable[i][j])
print tablenames
以上是我的代码,需要通过输入参数来访问 mysql 连接,但我无法使用该程序打印表名,有人可以帮我吗?非常感谢 !