Python split()方法
来源:互联网 发布:互联网金融的发展数据 编辑:程序博客网 时间:2024/06/04 00:56
原文地址:http://www.runoob.com/python/att-string-split.html
Python 字符串
描述
Python split()通过指定分隔符对字符串进行切片,如果参数num 有指定值,则仅分隔 num 个子字符串
语法
split()方法语法:
str.split(str="", num=string.count(str)).
参数
- str -- 分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等。
- num -- 分割次数。
返回值
返回分割后的字符串列表。
实例
以下实例展示了split()函数的使用方法:
#!/usr/bin/pythonstr = "Line1-abcdef \nLine2-abc \nLine4-abcd";print str.split( );print str.split(' ', 1 );
以上实例输出结果如下:
['Line1-abcdef', 'Line2-abc', 'Line4-abcd']['Line1-abcdef', '\nLine2-abc \nLine4-abcd']
阅读全文
0 0
- Python中的split方法
- Python split()方法
- python split() 方法
- Python str.split方法
- Python split()方法
- Python split()方法
- python join 和 split方法
- python中split实现字符串分割方法
- python正则表达式split()方法详解
- python join 和 split方法的使用
- Python中.split()和.join()方法对比
- split python
- python split
- python split
- python-split()
- Python split
- Python.split
- python .split()
- 系统环境变量和用户环境变量在注册表的那个位置
- 经典算法面试题 | 最少操作数使数组元素相等 I & II 大合集
- Dragonboard 410c MIPI CSI camera develop(1)
- 关于请求参数中文乱码的问题
- slidemenu+fragment+activity
- Python split()方法
- [LeetCode] 134. Gas Station
- 剑指offer c++
- Java和MATLAB混合编程,Java调用MATLAB代码
- win32 API获取当前进程的基质
- Android自定义控件之SurfaceView的使用
- FPGA入门笔记五 VHDL基本语法-框架
- C++实现汉诺塔问题
- 冒泡排序