python学习——Python center()方法
2016-05-17 00:00
288 查看
描述
Python center() 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串。默认填充字符为空格。语法
center()方法语法:str.center(width[, fillchar])
参数
width -- 字符串的总宽度。fillchar -- 填充字符。
返回值
该方法返回一个原字符串居中,并使用空格填充至长度 width 的新字符串。实例
以下实例展示了center()方法的实例:#!/usr/bin/python str = "this is string example....wow!!!"; print "str.center(40, 'a') : ", str.center(40, 'a')
以上实例输出结果如下:
str.center(40, 'a') : aaaathis is string example....wow!!!aaaa
相关文章推荐
- Python 面向对象
- Python3和2常用语句的语法区别3.0
- Python 识别文本编码
- Python 3 正则表达式对中文的匹配
- pythonchallenge 解谜 Level 1
- 文成小盆友python-num2 数据类型、列表、字典
- python数据分析之numpy初始化(一)
- python 中的map(), reduce(), filter
- python学习-day2
- python处理大数据
- Ubuntu下用pyenv进行python环境隔离
- 基于Python的朴素贝叶斯算法实现
- 动态内容爬虫
- python Image模块学习
- Python3写简单爬虫
- Python-----格式化字符
- leetcode(10),Roman to Integer(python)
- Python 格式化字符串
- Python点滴(五)-pandas进阶
- Windows下Eclipse+PyDev安装Python开发环境