对python 多个分隔符split 的实例详解
2019-01-04 00:02
751 查看
python中.split()只能用指定一个分隔符
例如:
text='3.14:15' print text.split('.')
输出结果如下:
['3', '14:15']
想一次指定多个分隔符可以用re模块
import re text='3.14:15' print re.split('[.:]', text)
输出结果如下:
['3', '14', '15']
以上这篇对python 多个分隔符split 的实例详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- python strip() 函数和 split() 函数的详解及实例
- python strip() 函数和 split() 函数的详解及实例
- python 中split 和 strip的实例详解
- python开发之for循环操作实例详解
- Python 操作MySQL详解及实例
- python的迭代器与生成器实例详解
- Python元组拆包和具名元组解析实例详解
- python单元测试unittest实例详解
- python数据结构之图深度优先和广度优先实例详解
- Python time模块详解(常用函数实例讲解,非常好)
- python字典创建和使用实例详解
- python3连接MySQL数据库实例详解
- Python 基础之字符串string详解及实例
- Python 带有参数的装饰器实例代码详解
- python生成二维码的实例详解
- Python 异常处理的实例详解
- python xml解析实例详解
- Python3.2中Print函数用法实例详解
- Python3中的列表生成式、生成器与迭代器实例详解
- 详解python脚本自动生成需要文件实例代码