我隻想要固定寬度的文本列,但字元串都填充正确,而不是左!
sys.stdout.write("%6s %50s %25s\n" % (code, name, industry))
産生
BGA BEGA CHEESE LIMITED Food Beverage & Tobacco
BHP BHP BILLITON LIMITED Materials
BGL BIGAIR GROUP LIMITED Telecommunication Services
BGG BLACKGOLD INTERNATIONAL HOLDINGS LIMITED Energy
但我們想要
BGA BEGA CHEESE LIMITED Food Beverage & Tobacco
BHP BHP BILLITON LIMITED Materials
BGL BIGAIR GROUP LIMITED Telecommunication Services
BGG BLACKGOLD INTERNATIONAL HOLDINGS LIMITED Energy