手机
当前位置:查字典教程网 >脚本专栏 >python >Python ljust rjust center输出
Python ljust rjust center输出
摘要:看下面的例子就会明白了:复制代码代码如下:print'|','*'.ljust(10),'|'print'|','*'.ljust(10,'...

看下面的例子就会明白了:

复制代码 代码如下:

print '|','*'.ljust(10),'|'

print '|','*'.ljust(10,'-'),'|'

print '|','*'.rjust(10,'-'),'|'

print '|','*'.center(10,'-'),'|'

for a in range(1, 6):

print 'a = '.ljust(5), repr(a).ljust(10), 'b = '.ljust(5), repr(a * 2)

输出结果:

| * |

| *--------- |

| ---------* |

| ----*----- |

a = 1 b = 2

a = 2 b = 4

a = 3 b = 6

a = 4 b = 8

a = 5 b = 10

【Python ljust rjust center输出】相关文章:

Python subprocess模块学习总结

Python urlopen 使用小示例

python检测lvs real server状态

Python Web框架Pylons中使用MongoDB的例子

Python中的CURL PycURL使用例子

python 解析html之BeautifulSoup

使用python Django做网页

python list转dict示例分享

python在linux中输出带颜色的文字的方法

Python urllib模块urlopen()与urlretrieve()详解

精品推荐
分类导航