1. 首页
  2. 数据库
  3. 其它
  4. Python ljust rjust center输出

Python ljust rjust center输出

上传者: 2020-12-31 18:08:22上传 PDF文件 16KB 热度 14次
看下面的例子就会明白了: 复制代码 代码如下: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
下载地址
用户评论