2019-02-12
阅读量:
860
python如何使用String方法格式化输出
在python的输出中使用字符串切片和连接操作进行格式化。字符串类型有一些方法可以帮助以更高级的方式格式化输出。
# Python program to
# format a output using
# string() method
cstr = "I love geeksforgeeks"
# Printing the center aligned
# string with fillchr
print ("Center aligned string with fillchr: ")
print (cstr.center(40, '#'))
# Printing the left aligned
# string with "-" padding
print ("The left aligned string is : ")
print (lstr.ljust(40, '-'))
# Printing the right aligned string
# with "-" padding
print ("The right aligned string is : ")
print (rstr.rjust(40, '-'))
0.0000
0
4
关注作者
收藏
评论(0)
发表评论
暂无数据
推荐帖子
0条评论
0条评论
0条评论

