Python ljust rjust center输出
时间:2021-05-13 04:19:25
看下面的例子就会明白了:
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
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
如何实现My SQL中的用户的管理问题
2008-12-03 13:56:00
常用Oracle分析函数大全
2023-07-03 08:16:14
![](https://img.aspxhome.com/file/2023/0/63710_0s.jpg)
为什么JavaScript中正则表达式的test方法会出错?
2009-03-17 12:38:00
php关于array_multisort多维数组排序的使用说明
2023-09-07 08:13:27
使用Perl语言去存取mSQL和MySQL数据库的内容
2009-10-23 09:11:00
Python新手学习标准库模块命名
2021-01-16 05:18:06
深入了解Python的异常处理机制
2023-09-03 09:25:41
![](https://img.aspxhome.com/file/2023/6/68886_0s.png)
JS 显示当前日期+星期(静态)
2007-09-11 13:29:00
tensorflow 重置/清除计算图的实现
2023-07-23 00:41:58
mysql UNIX时间戳与日期的相互转换
2010-02-10 12:10:00
用ASP实现IE地址栏参数的判断
2008-10-10 15:54:00
分享8点超级有用的Python编程建议(推荐)
2022-03-31 08:05:57
![](https://img.aspxhome.com/file/2023/2/66432_0s.png)
python openpyxl使用方法详解
2021-12-23 14:49:18
支付宝lab logo设计创意发想
2009-11-12 12:44:00
![](https://img.aspxhome.com/file/UploadPic/200911/12/blog1-38s.jpg)
基于PHP做个图片防盗链
2023-05-25 00:27:30
如何判断SQL语句是否执行了?
2010-01-12 20:03:00
ASP连接MSSQL的错误: 拒绝访问
2008-11-23 20:40:00
django admin 自定义替换change页面模板的方法
2022-01-15 11:19:30
![](https://img.aspxhome.com/file/2023/9/71369_0s.jpg)
Mysql5写中文乱码问题解决
2007-09-17 12:38:00
Oracle备库宕机启动的完美解决方案
2023-07-20 05:28:34
![](https://img.aspxhome.com/file/2023/9/64079_0s.png)