python str.center()

mac2022-06-30  25

print('while循环'.center(20,'-'))>>> ------while循环-------

str.center(width[, fillchar])

Return centered in a string of length width. Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to len(s).

 

翻译:返回一个居中过的字符串,用指定字符填充(默认是用ascii位置)

原始的字符串的宽度小于或者等于len(s)的话就返回原始字符串

 

转载于:https://www.cnblogs.com/ezway/p/6347852.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)