Python 中的join()与split()
来源:互联网 发布:阿里云学生认证学信网 编辑:程序博客网 时间:2024/05/12 11:13
1. join()
1. join()的介绍
2. Code
#1)对序列进行操作LIST =["I","am","bigship","come","from","China"]print string.join(LIST," ")print ' '.join(LIST)#2)对字符串进行操作str="i am bigship"print string.join(str,"->")print '->'.join(str)#3)对元组进行操作TUPLE = ("I","am","bigship","come","from","China")print string.join(TUPLE," ")print ' '.join(TUPLE)#4)对字典进行操作Dir ={'b':1,'i':2,'g':3,'s':4,'h':5,'p':7}print string.join(Dir,':')print ':'.join(Dir)
3. Input/Output
I am bigship come from ChinaI am bigship come from Chinai-> ->a->m-> ->b->i->g->s->h->i->pi-> ->a->m-> ->b->i->g->s->h->i->pI am bigship come from ChinaI am bigship come from Chinab:g:i:h:p:sb:g:i:h:p:s
2. split()
1. split()的简单介绍
- 分隔符
seg 默认为空格. num 表示分割的次数,默认为seg 的个数,可以形成num+1 个切片.[n] 表示选取第n 个切片
2. Code
str = "welcome to Harbin, it's a beautiful place"print str.split(' ')print str.split()print str.split(' ',3)print str.split(' ')[2]
3. Input/Output
['welcome', 'to', 'Harbin,', "it's", 'a', 'beautiful', 'place']['welcome', 'to', 'Harbin,', "it's", 'a', 'beautiful', 'place']['welcome', 'to', 'Harbin,', "it's a beautiful place"]Harbin,
1 0
- Python 中的join()与split()
- Python 中的join()与split()
- python:split与join
- Python中的join和split
- python中的join和split
- python之string中的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 ''.join,split(),strip()
- Python中的join()函数和split()函数的用法
- Python中的join()函数和split()函数的用法
- JSON工具类
- VBS脚本运行后删除自身的方法
- ubuntu下对php环境的配置步骤
- Tomcat内存优化4 求根索源——工具 JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、hprof使用详解
- AndroidStudio实现JNI的示例详解
- Python 中的join()与split()
- API读取写入 ini文件内容的方法函数详解
- CSS3阴影 box-shadow的使用和技巧总结
- swift 快速奔跑的兔几 本节的内容是:序列化与反序列化
- Android 编程规范与常用技巧
- 【Android开发—智能家居系列】(一):智能家居原理
- 网站域名的选择
- Jsonlib实现Json字符串和Java对象的互相转换
- Java:单例模式的七种写法