# -*- coding: cp936 -*-
#python 27
#xiaodeng
#str方法之ljust、rjust、center
#http://www.runoob.com/python/att-string-rjust.html '''
语法:
str.rjust(width[, fillchar])
参数:
width -- 指定填充指定字符后中字符串的总长度.
fillchar -- 填充的字符,默认为空格。
''' #ljust左对齐
str='xiaodeng'
print str.ljust(20,'-')#使用短横线做填充 #rjust右对齐
print str.rjust(20,'-') #center居中对齐
print str.center(20,'-')

python str方法之ljust、rjust、center的更多相关文章

  1. Python: ljust()|rjust()|center()字符串对齐

    通过某种对齐方式来格式化字符串 ①对于基本的操作,可以使用字符串的ljust(),rjust(),center() ②函数format()同样可以用来很容易的对齐字符串,使用<,>,~

  2. Python str方法总结

    1.返回第一个字母大写 S.capitalize(...) S.capitalize() -> string 1 2 3 4 >>>a = 'shaw' >>> ...

  3. python ljust,rjust,center,zfill对齐使用方法

    字符串在输出时的对齐:S.ljust(width,[fillchar]) #输出width个字符,S左对齐,不足部分用fillchar填充,默认的为空格. S.rjust(width,[fillcha ...

  4. python center, ljust, rjust

    例子 >>> s = "jihite" >>> s.center(, "*") '**jihite**' >>& ...

  5. Python之str方法

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #Python之str方法 #http://python.jobbole.com/82655/ #str为一个 ...

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

    简介Python中用于处理字符串的center()方法 这篇文章主要介绍了简介Python中用于处理字符串的center()方法,是Python入门中的基础知识,需要的朋友可以参考下 center() ...

  7. python - str和repr方法:

    # python 内置__str__()和__repr__()方法: #显示自定制 # 示例1 # a = 123 # print(a.__str__()) # 示例2 class Test(): d ...

  8. #python str.format 方法被用于字符串的格式化输出。

    #python str.format 方法被用于字符串的格式化输出. #''.format() print('{0}+{1}={2}'.format(1,2,3)) #1+2=3 可见字符串中大括号内 ...

  9. Python 字典(Dictionary) str()方法

    Python 字典(Dictionary) str()方法 描述 Python 字典(Dictionary) str() 函数将值转化为适于人阅读的形式,以可打印的字符串表示.高佣联盟 www.cge ...

随机推荐

  1. 使用强大的 Mockito 测试框架来测试你的代码

    原文链接 : Unit tests with Mockito - Tutorial 译文出自 : 掘金翻译计划 译者 : edvardhua 校对者: hackerkevin, futureshine ...

  2. Keras教程

    In this step-by-step Keras tutorial, you’ll learn how to build a convolutional neural network in Pyt ...

  3. [转]redis配置文件redis.conf的详细说明

    转自: http://www.sufeinet.com/thread-8047-1-1.html # Redis 配置文件 # 当配置中需要配置内存大小时,可以使用 1k, 5GB, 4M 等类似的格 ...

  4. 用EntityFramework6完成增删查改和事务【转】

    http://www.cnblogs.com/wujingtao/p/5407821.html 上一节我们已经学习了如何使用EF连接数据库,并简单演示了一下如何使用EF6对数据库进行操作,这一节我来详 ...

  5. Android Studio中实现AIDL

    AIDL 先来两个传送门: http://www.cnblogs.com/yydcdut/p/3961545.html Android面试,与Service交互方式 http://www.cnblog ...

  6. Git创建分支/GIT提交分支

    git clone xxx.git cd fwspp-react git init touch README.md git add README.md git commit -m "add ...

  7. 【python】安装bcoding

    C:\Users\horn1>pip install bcodingCollecting bcoding Downloading https://files.pythonhosted.org/p ...

  8. 【python】理想论坛爬虫1.08

    #------------------------------------------------------------------------------------ # 理想论坛爬虫1.08, ...

  9. 大量带BPM的跑步歌曲/跑步音乐下载

    20150110停止更新告知:不知不觉本帖更新有近半年了.从最开始跑步已经四年多,一直是听着音乐跑的,音乐支持.陪伴.丰富着我的跑步之旅.直到上个月因一次觉得音乐吵,我开始有意地摘掉耳机去跑步,并开始 ...

  10. notepad++列块编辑操作

    1. 同一时候编辑连续的列区域: 鼠标先在要进行列编辑的起点点击,再同一时候按shift+alt不放,鼠标在要进行列编辑的结尾区域点击. 2. 在起点到文档结尾全部列插入数据: 鼠标先在要插入数据的位 ...