Pretty Print Formatting Issue in Python -


 str = ""  in range(1,91):      str = str + '-'   print "+", '{:^90}'.format(str), "+"  elem in cursor:      print "|", '{:^8}'.format(elem['classid']), \            "|", '{:^8}'.format(elem['dept']), \            "|", '{:^8}'.format(elem['coursenum']), \            "|", '{:^8}'.format(elem['area']), \            "|", '{:<46}'.format(elem['title']), \           "|"  print "+", '{:^90}'.format(str), "+" 

i have following code in place try , print out results of db query. in standalone file, prints following output:

+ ------------------------------------------------------------------------------------------ + | centered | centered | centered | centered | 12                                             | | centered | centered | centered | centered | 12                                             | | centered | centered | centered | centered | 12                                             | + ------------------------------------------------------------------------------------------ + 

when placed in larger file within function, not work however. following error:

  file "reg.py", line 58, in printhumanoutput     print "+", '{:^90}'.format(''), "+" valueerror: 0 length field name in format 

help?

python 2.6 not support zero-length field names in format strings.

print "+", '{0:^90}'.format(''), "+" 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -