摘要: s1='alex' s2='+'.join(s1) print(s2,type(s2)) a+l+e+x l1=['小红','小刚','小明'] 前提:列表中的元素必须都是str类型 s3=':'.join(l1) 将一个列表返回一个字符串如下: print(s3) 小红:小刚:小明 print(' 阅读全文
posted @ 2019-06-16 17:17 God_with_us 阅读(874) 评论(0) 推荐(0) 编辑
摘要: 1.v = 'k1,v1 k2,v2 k3,v3 '变成一个字典{'k1':'v1','k2':'v2','k3:'v3'...} 变成一个字典 {'k1':'v1','k2':'v2','k3:'v3'...} 第一种: ''' v=v.split(' ')直接分割 返回值 ['k1,v1', ' 阅读全文
posted @ 2019-06-15 19:18 God_with_us 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 有如下车牌和车辆归属地,形成一个新的字典,显示每个归属地的车辆共有多少: cars = ['鲁A32444','鲁B12333','京B8989M','⿊C49678','⿊C46555','沪B25044','冀G11111','⿊C42355'] locals = {'冀':'河北', '⿊': 阅读全文
posted @ 2019-06-14 20:23 God_with_us 阅读(268) 评论(1) 推荐(0) 编辑
摘要: s.upper lower 全部大写 小写 s.caplitalize 首字母大写 s.strip 去空格 空行 startswith enswith 判段以什么开头 结尾 s.replace默认全部替换,可设置次数 print(s[:: 1])字符串的反向取值 print(s.split)字符串的 阅读全文
posted @ 2019-06-13 18:10 God_with_us 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1. str int 字符串中必须都是十进制的数,才能进行转换 2. int str 3. str list 面试题: 把字符串转换成列表 print(s.split()) 把列表转换成字符串 print(''.join(li)) 4. list str 5. list tuple 6. tuple 阅读全文
posted @ 2019-06-12 21:27 God_with_us 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1. 首字母大写 2.每个单词首字母大写 title 3,统计出现的次数 count 4.大小写转换 swapcase 5.查找(通过元素名字找到元素的索引) 6.list 7.统计 8.查看 9.反转 10.排序 11.tuple,统计,查找 12.dict: 13.批量创建字典 14.set: 阅读全文
posted @ 2019-06-12 21:26 God_with_us 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1.赋值 2.浅拷贝 3.深copy 例1: 阅读全文
posted @ 2019-06-11 17:31 God_with_us 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 集合set,容器型的数据类型,它要求里面的元素是不可变的数据,但它本身是可变的数据类型,集合是无序的的.{} 集合的创建 set1=set({1,2,'barue','False'}) set1={1,3,'小刚',4,False,'人生'} print(set1) python 什么是集合? se 阅读全文
posted @ 2019-06-11 17:30 God_with_us 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 15.小数据池 小数据池就是python 中一种提高效率的方式,固定数据类型使用同一个内存地址 小数据池 支持:str,int,bool 前提:不同代码块的缓存机制 缓存机制的优点:提升性能,节省内存。 小数据池怎么用? 小数据池数字范围: 5~256 字符串: 1.字符串在做乘法的时候总长度不能超 阅读全文
posted @ 2019-06-11 17:29 God_with_us 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 数据类型的分类(可变与不可变): 可变(不可哈希)的数据类型:list dict set 不可变(可哈希)的数据类型: str bool int tuple 字典:{}括起来,以健值对形式存储的容器型数据类型: 键必须是不可变的数据类型,int str(bool tuple几乎不用)唯一的 值可以是 阅读全文
posted @ 2019-06-10 19:15 God_with_us 阅读(134) 评论(0) 推荐(0) 编辑