python字符串格式输出
2018-02-01 23:01
246 查看
s = "hello" print(s.capitalize()) # Capitalize a string; prints "Hello" print(s.upper()) # Convert a string to uppercase; prints "HELLO" print(s.rjust(7)) # Right-justify a string, padding with spaces; prints " hello" print(s.center(7)) # Center a string, padding with spaces; prints " hello " print(s.replace('l', '(ell)')) # Replace all instances of one substring with another; # prints "he(ell)(ell)o" print(' world '.strip()) # Strip leading and trailing whitespace; prints "world"
相关文章推荐
- Python 字符串输出格式总结
- Python学习(三) 输出任意格式的字符串以及字符串的切片
- Python把一段字符串用“右起竖排”的古文格式输出
- Python字符串操作符(%s,%d,%u...)与输出格式控制(*-+#0...)
- python之字符串输出更好的格式控制
- python 下字符串格式时间比较
- 腾讯笔试题:输入16的倍数个字符串,按格式排版输出
- python中json格式数据输出实现方式(无unicode编码输出形式)
- python爬虫由浅入深5--的html格式输出 prettify()
- 关于vs2010 中c++输出字符串到txt文件中的格式问题
- python2 python3 字符串 编码格式 处理
- python 4-3 如何调整字符串中文本格式re.sub(p,r'\1/\2',str1)/re.sub('(?P<Name>p),'\g<Name>',str1)
- python 用函数strptime判断字符串是否为日期格式
- Python读取文本,输出指定中文(字符串)
- python将字符串格式日期转换为excel的日期格式
- python 日志输出格式配置
- 用jquery获取xml页面 以json字符串格式输出
- poi导出excel,以字符串格式输出数字
- python difflib模块实现两个文件差异对比,并输出html格式。
- 自定义数字格式字符串输出示例