1、strip, lstrip, rstrip

x = '       jiahuifeng    '
print(x.strip(' '))
print(x.lstrip(' '))
print(x.rstrip(' '))

2、lower ,upper

x = 'jiahuifeng'
print(x.lower())
print(x.upper())

3、startswith,endswith

x = 'fengjiahui_haha'
print(x.startswith('fe'))
print(x.endswith('_haha'))

4、格式化输出

print('My name is %s,my age is %s' %('jiahuifeng',18))
print('{} {} {}'.format('jiahuifeng',18,'male'))

5、split , splitlines

name='root:x:0:0::/root:/bin/bash'
print(name.split(':')) #默认分隔符为空格 name='C:/a/b/c/d.txt' #只想拿到顶级目录
print(name.split('/',1)) name='a|b|c'
print(name.rsplit('|',1)) #从右开始切分 name = '''ab c
de fgkl
sadfewf'''
print (name.splitlines())

6、join

name=' '
print(tag.join(['egon','say','hello','world'])) -->egon say hello world

7、replace

name='jiahuifeng say :i have one apple,my name is jiahuifeng'
print(name.replace('jiahuifeng','qiqi',1))

8、拼接

x = 'jiahuifeng'
y = 'shi'
z = 'haha' name = x+y+z
print(name)

最新文章

  1. IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
  2. Premiere Pro & After Effects插件开发调试方法
  3. 如何获得DataGrid中某行某列的对象
  4. Python开发【第十二篇】:DOM
  5. [Cocos2d-x For WP8]ActionManager动作管理
  6. U-boot.lds文件分析
  7. C++中数组求偏移量计算公式
  8. oracle数据库导入导出命令!
  9. 命令行下玩VC
  10. Jquer学习
  11. mysql嵌套查询
  12. C#调用SAPWebService
  13. MVC模式编程演示样本-登录认证(静态)
  14. PPPOE拨号上网流程及密码窃取具体实现
  15. 1 开发环境 eclipse oomph版本 jdk1.8 lucene 6.6.0,luke6.6.0
  16. 51Nod1824 染色游戏 【Lucas定理】【FMT】【位运算】
  17. Python3学习笔记21-实例属性和类属性
  18. Notes for Neural Network Methods for Natural Language Processing
  19. angularjs初识ng-app、ng-model、ng-repeat指令
  20. 【BZOJ2164】采矿 树链剖分+线段树维护DP

热门文章

  1. .NETFramework:Stream
  2. ASP.NET Core:template
  3. 架构-MVVM:MVVM核心概念
  4. opencord视频截图
  5. HDU 5879 Cure (数论)
  6. J20170426-hm
  7. dijkstra算法的应用(poj2387)+堆优化【还没学C艹很尴尬,不理解的先不写了,未完,待续...】
  8. 第十二篇 .NET高级技术之lambda表达式
  9. 温习LOGO语言
  10. Codeforces Round #408 (Div. 2) A