各种对list,string操作函数的总结
#encoding=utf-8
#reverse,用来反转list
a=['aa','bb','cc']
a.reverse()
print a#['cc', 'bb', 'aa']
#不能直接print a.reverse(),报None
#'tuple','dict','str' object has no attribute 'reverse',不能jiang字符串reverse
#join以指定连接符连接tuple,list,strin,dict,输出为str类型
seq1 = ['hello','good','boy','doiido']
print ':'.join(seq1)#hello:good:boy:doiido
seq2 = ('hello','good','boy','doiido')
print ':'.join(seq2)
seq3 = {'hello':1,'good':2,'boy':3,'doiido':4}
print ':'.join(seq3)#boy:good:doiido:hello输出是乱的
seq4 = 'hello good boy doiido'
print ':'.join(seq4)#h:e:l:l:o: :g:o:o:d: :b:o:y: :d:o:i:i:d:o
#split拆分字符串
a='hello good boy doiido'
print a.split()#['hello', 'good', 'boy', 'doiido']输出是list,括号内是根据什么字符来分割
#'list','tuple','dict' object has no attribute 'split'
#append,insert,remove,pop用法,只能操作list
b=['hello','good','boy','doiido']
b.append('hola')
print b#['hello', 'good', 'boy', 'doiido', 'hola']
b.insert(2,'luck')#['hello', 'good', 'luck', 'boy', 'doiido', 'hola']
print b
b.remove('hola')#['hello', 'good', 'luck', 'boy', 'doiido']
print b
print b.pop()#doiido,str类型
print b#['hello', 'good', 'luck', 'boy']
各种对list,string操作函数的总结的更多相关文章
- C++:string操作函数
要想使用标准C++中string类,必须要包含 #include <string>// 注意是<string>,不是<string.h>,带.h的是C语言中的头文件 ...
- (转) Lua string 操作函数
本文转自: http://www.cnblogs.com/newlist/p/3649388.html table.keys 返回指定表格中的所有键. 格式: keys = table.keys(表格 ...
- 字符串操作函数<string.h>相关函数strcpy,strcat,等源码。
首先说一下源码到底在哪里找. 我们在文件中包含<cstring>时,如果点击右键打开文档, 会打开cstring,我们会发现路径为: D:\Program Files\visual stu ...
- python中string的操作函数
在python有各种各样的string操作函数.在历史上string类在python中经历了一段轮回的历史.在最开始的时候,python有一个专门的string的module,要使用string的方法 ...
- string操作
常用的功能测试: #! -*- coding:utf-8 -*- import string s = 'Yes! This is a string' print '原字符串:' + s print ' ...
- Delphi中复制带有String的记录结构时不能使用Move之类的内存操作函数
请看下面的代码: program TestRecord; {$APPTYPE CONSOLE} uses SysUtils, Math; type TRecordA = record Na ...
- Python中字符串操作函数string.split('str1')和string.join(ls)
Python中的字符串操作函数split 和 join能够实现字符串和列表之间的简单转换, 使用 .split()可以将字符串中特定部分以多个字符的形式,存储成列表 def split(self, * ...
- dedecms功能性函数封装(XSS过滤、编码、浏览器XSS hack、字符操作函数)
dedecms虽然有诸多漏洞,但不可否认确实是一个很不错的内容管理系统(cms),其他也不乏很多功能实用性的函数,以下就部分列举,持续更新,不作过多说明.使用时需部分修改,你懂的 1.XSS过滤. f ...
- Delphi文件操作函数
文件是同一种类型元素的有序集合,是内存与外设之间传输数据的渠道.文件的本质是一个数据流,所有的文件实际上是一串二进制序列.文件管理包括:1.文件操作.2.目录操作.3.驱动器操作.三部分. 1.常见文 ...
随机推荐
- Hibernate之CRUD实践
Hibernate作为一个高度封装的持久层框架,曾经是非常牛逼的,现在虽然应用不是特别广,比如我前公司主要是做OA的,应用的框架就是Spring+SpringMVC+Hibernate. Hibern ...
- C#中Form的Paint事件响应方法与重载虚方法OnPaint()的区别
Form_Paint()方法是Paint事件的响应方法,OnPaint是可重载的虚方法,OnPaint方法是调用Paint事件的,用哪一个,效果是一样,就看那一个方便了内部是这样实现的: protec ...
- Redis(RedisTemplate)运算、算法(incr、decr、increment)
RedisTemplate配置:https://www.cnblogs.com/weibanggang/p/10188682.html package com.wbg.springRedis.test ...
- HDU 2030 汉字统计(汉字Asics码为负,占两个char)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2030 汉字统计 Time Limit: 2000/1000 MS (Java/Others) M ...
- The App Life Cycle & The Main Function
The App Life Cycle Apps are a sophisticated interplay between your custom code and the system framew ...
- 第26章 FMC—扩展外部SDRAM
本章参考资料:<STM32F76xxx参考手册2>.<STM32F7xx规格书>.库帮助文档<STM32F779xx_User_Manual.chm>. 关于SDR ...
- 创建oracle数据库表空间并分配用户
我们在本地的oracle上或者virtualbox的oracle上 创建新的数据库表空间操作:通过system账号来创建并授权/*--创建表空间create tablespace YUJKDATAda ...
- 我的前端工具集(七)div背景网格
我的前端工具集(七)div背景网格 liuyuhang原创,未经允许禁止转载 目录 我的前端工具集 有时候总觉得div颜色过于白,于是给了10%的灰 但是并不一定能解决问题,因为页面中会有不均衡的 ...
- js 获取任意一个元素的任意一个样式属性的值
//谷歌,火狐支持console.log(window.getComputedStyle(my$("dv"),null).left);//IE8支持console.log(my$( ...
- acm--1006
Problem Description The three hands of the clock are rotating every second and meeting each other ma ...