I am reading data from a MySQL database and want to print it to the screen.
I use:
import MySQLdb
conn = MySQLdb.connect(host='localhost',user='root',passwd='passwd',db='test',charset='utf8')
cursor = conn.cursor()
cursor.execute('select cust_name,cust_address,cust_city,cust_state from Customers')
numrows = int(cursor.rowcount)
for i in range(numrows):
row = cursor.fetchone()
print "%s %s %s %20s" %(row[0],row[1],row[2],row[3])
cursor.close()
conn.close()
The result is like this:
Village Toys 200 Maple Lane Detroit MI Kids Place 333 South Lake Drive Columbus OH Fun4All 1 Sunny Place Muncie IN Fun4All 829 Riverside Drive Phoenix AZ The Toy Store 4545 53rd Street Chicago IL
How can i make it left justified?