• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > 简介Python中用于处理字符串的center()方法

简介Python中用于处理字符串的center()方法

作者:goldensun 字体:[增加 减小] 来源:互联网

goldensun 通过本文主要向大家介绍了python center,python center函数,python字符串处理,python 格式化字符串,python 字符串等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

 center()方法返回集中在长度宽度的字符串。填充是通过使用specifiedfillchar。默认填充字符是一个空格。
语法

以下是center()方法的语法:

str.center(width[, fillchar])

</div>

参数

  •     width -- 这是字符串的总宽度。
  •     fillchar -- 这是填充符。

返回值

此方法返回集中在长度宽度的字符串。
例子

下面的示例演示center()方法的使用。

#!/usr/bin/python

str = "this is string example....wow!!!";

print "str.center(40, 'a') : ", str.center(40, 'a')

</div>

当我们运行上面的程序,它会产生以下结果:

str.center(40, 'a') : aaaathis is string example....wow!!!aaaa

</div>

</div>

您可能想查找下面的文章:

  • 简介Python中用于处理字符串的center()方法
  • Python ljust rjust center输出

相关文章

  • Python 变量类型及命名规则介绍
  • python实现指定字符串补全空格的方法
  • Python过滤列表用法实例分析
  • Python自动扫雷实现方法
  • Python的函数的一些高阶特性
  • python利用Guetzli批量压缩图片
  • Python实现把回车符\r\n转换成\n
  • python每隔N秒运行指定函数的方法
  • Python3搜索及替换文件中文本的方法
  • 深入解析Python编程中JSON模块的使用

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 详细解读Python中解析XML数据的方法
    • Python中正则表达式的用法实例汇总
    • Django中实现一个高性能计数器(Counter)实例
    • python使用beautifulsoup从爱奇艺网抓取视频播放
    • python中as用法实例分析
    • Python实现设置windows桌面壁纸代码分享
    • python3.5实现socket通讯示例(TCP)
    • python实现按任意键继续执行程序
    • python中安装模块包版本冲突问题的解决
    • 浅析python中SQLAlchemy排序的一个坑

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有