python split分隔字符串之分隔次数
2012-12-28 13:31
337 查看
使用格式:
str.split("char",num)
char:表示分隔标识符
num:表示分隔最大次数,为空表示分隔所有
python 示例代码split.py:
执行split.py,结果如下:
str.split("char",num)
char:表示分隔标识符
num:表示分隔最大次数,为空表示分隔所有
python 示例代码split.py:
#!/usr/bin/python # -*- coding: UTF-8 -*- str="www.baidu.com.cn" strtemp=str.split(".",1) print strtemp[0] print strtemp[1] print strtemp print str strtemp=str.split(".",3) print strtemp[0] print strtemp[1] print strtemp[2] print strtemp[3] print strtemp print str
执行split.py,结果如下:
~$ sudo python split.py www baidu.com.cn ['www', 'baidu.com.cn'] www.baidu.com.cn www baidu com cn ['www', 'baidu', 'com', 'cn'] www.baidu.com.cn
相关文章推荐
- Python使用split使用多个字符分隔字符串
- Python使用split使用多个字符分隔字符串
- C# Split分隔字符串的应用(C#、split、分隔、字符串)
- C#中Split用法~ C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- Python_连接List与分割字符串_join&split
- SQL自定义函数split分隔字符串
- python字符串分隔
- python split使用多个分隔符分割字符串
- 在Python中用split()方法分割字符串的使用介绍
- Python3基础 str count 得到一个字符串出现的次数
- python统计指定文件中指定字符或字符串出现的次数
- C#中Split分隔字符串的应用
- oracle 拆分逗号分隔字符串 实现split
- oracle拆分逗号分隔字符串 实现split
- Qt字符串和java字符串的split方法比较和python的解析比较
- C#中使用Split分隔字符串的技巧
- Python—求一个字符串中每个字符出现的次数
- C#中Split分隔字符串的应用(C#、split、分隔、字符串)
- asp.net下Split分隔字符串的应用
- c# 以多个字符串分隔字符串数据 分组 分隔 split 正则分组