Python split
2016-03-23 19:08
543 查看
Syntax
Following is the syntax for split() method −str.split(str="", num=string.count(str)).
Parameters
str -- This is any delimeter, by default it is space.num -- this is number of lines to be made
Return Value
This method returns a list of lines.
Example
The following example shows the usage of split() method.#!/usr/bin/python str = "Line1-abcdef \nLine2-abc \nLine4-abcd"; print str.split( ) print str.split(' ', 1 )
When we run above program, it produces following result −
['Line1-abcdef', 'Line2-abc', 'Line4-abcd'] ['Line1-abcdef', '\nLine2-abc \nLine4-abcd']
相关文章推荐
- Python~第三方模块
- KNN python实践
- 在Python里安装Jieba中文分词组件
- Pythonj~module
- think python学习心得-(3)条件和递归
- Python文档生成工具pydoc使用介绍
- 初学者必知的Python中优雅的用法
- python编辑器pydev安装
- python+selenium环境搭建
- [python]int函数带参用法
- python转成window可执行.exe文件
- Python爬取鬼吹灯2(周建龙)(PyV8解析js)
- Python爬虫利器二之Beautiful Soup的用法
- A Byte of Python (1)安装和运行
- Selenium+WebDriver+Python 定时控制任务
- Python os.path
- python paramiko模块使用介绍
- numpy、scipy、matplotlib安装与配置
- python之psutil模块获取系统信息
- python类、对象、方法、属性之类与对象笔记