python 取代字符串中的某项 replace,split, join
来源:互联网 发布:配置php开发环境 编辑:程序博客网 时间:2024/05/29 08:12
首先需要:import string
然后有两种方法取代字符串中的某项:
方法1:
>>> a='...hello...the....world............'
>>> b=a.replace('.',' ')
>>> print b
hello the world
方法2:
>>> a='...hello...the....world............'
>>> b=string.replace(a,'.',' ')
>>> print b
hello the world
split函数:
>>> print b
hello the world >>>list1=b.split()#把空格过滤出去,剩下的组成一个list,也可以在split()的括号里传入一个参数
>>> print list1
['hello', 'the', 'world']
join函数:
>>> list1
['hello', 'the', 'world']
>>> delimiter=' '>>> line=delimiter.join(list1)
>>> print line
hello the world
0 0
- python 取代字符串中的某项 replace,split, join
- python字符串处理 join split replace的使用方法
- Python中的join和split
- Python 中的join()与split()
- Python 中的join()与split()
- python中的join和split
- python--uuid--字符串split--join(列表)
- js中replace()、join()、split()的用法
- python join 和 split
- python join 和 split
- python join and split
- python join 和 split
- [python]split 和 join
- python\split\join
- python join 和 split
- python:split与join
- python split , join 命令
- python split() join()
- Java线程:概念与原理
- C++字符串学习(三)
- 函数指针的用途
- 聊聊R的优势
- Oralce中delete和delete from
- python 取代字符串中的某项 replace,split, join
- 输入两个整数序列。其中一个序列表示栈的push顺序, 判断另一个序列有没有可能是对应的pop顺序。 为了简单起见,我们假设push序列的任意两个整数都是不相等的
- UVALive2889 Palindrome Numbers(回文数,神级代码....)
- Qt入门可能会遇到的一些问题
- 括号匹配(二)
- Object-c对象和消息传递
- Servlet详解
- MFC-GUI绘图相关摘要
- 阿里云ECS+Gunicorn+Supervisor+Nginx部署Flask