MySQL データベースからデータを読み取っていて、それを画面に出力したいと考えています。
私が使う:
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()
結果は次のようになります。
Village Toys 200 メープルレーン デトロイト ミシガン州 キッズプレイス 333 South Lake Drive コロンバス オハイオ州 Fun4All 1 サニー プレイス マンシー イン Fun4All 829 リバーサイド ドライブ アリゾナ州フェニックス おもちゃ屋 4545 53rd Street シカゴ IL
どうすれば左揃えにできますか?