代码如下:
#encoding=utf-8
print '中国'
#字符串对齐
print '|','abc中国'.ljust(20),'|','abc中国'.rjust(20),'|','abc中国'.center(20),'|'
print u'|',u'abc中国'.ljust(20),u'|',u'abc中国'.rjust(20),u'|',u'abc中国'.center(20),u'|'
print u'|',u'abc中国'.ljust(20,'-'),u'|',u'abc中国'.rjust(20,'-'),u'|',u'abc中国'.center(20,'-'),u'|'
打印结果如下:
中国
| abc中国 | abc中国 | abc中国 |
| abc中国 | abc中国 | abc中国 |
......
阅读全文