zoukankan      html  css  js  c++  java
  • day06-2 数据结构

    #__author: hasee
    #date:  2018/2/4
    
    
    # dic={1:'liu','age':35,'hobby':{'girl_name':'金箍棒','age':45},'is_handsome':True}
    # dic={'age':'liu','age':35,'hobby':{'girl_name':'金箍棒','age':45},'is_handsome':True}
    #
    # print(dic)
    
    #字典两大特点:无序,键唯一
    
    
    #字典的创建
    # a=list()
    # print(a)
    
    # dic={'name':'liu'}
    
    # dic1={}
    # dic2=dict((('name','liu'),))       #元组单个需要加,
    # print(dic2)
    
    # dic3=dict([['name','liu'],])   #外面这个括号是dict进行传参的,里面的第一层【】表示列表,第二层【】表示列表里面嵌套的列表
    # print(dic3)
    
    
    
    
    # dic1={'name':'liu'}
    # dic1['age']=18      #增加字典
    # print(dic1)
    
    #键存在,不改动,返回字典中相应的键对应的值
    # ret=dic1.setdefault('age',34)
    # print(ret)
    #
    # #键不存在,在字典中中增加新的键值对,并返回相应的值
    # ret2=dic1.setdefault('hobby','girl')
    # print(dic1)
    # print(ret2)
    
    #查  通过键去查找
    # dic3={'age': 18, 'name': 'liu', 'hobby': 'girl'}
    #
    # print(dic3['name'])
    #
    # print(list(dic3.keys()))   #将键保存到列表中
    # print(list(dic3.values()))  #将值保存到列表
    # print(list(dic3.items()))   #将键和值以元组的形式保存到列表中
    
    # li=[1,2,34,4]
    # li[2]=5
    # dic3={'age': 18, 'name': 'liu', 'hobby': 'girl'}
    # dic3['age']=55
    # print(dic3)
    
    # dic4={'age': 18, 'name': 'liu', 'hobby': 'girl'}
    # # dic5={'1':'111','2':'222'}
    # dic5={'1':'111','name':'222'}
    #
    # dic4.update(dic5)  #更新覆盖,已有的直接覆盖
    # print(dic4)
    # print(dic5)
    
    
    
    
    
    
    
    
    
    # dic5 = {'name': 'alex', 'age': 18, 'class': 1}
    
    # dic5.clear() # 清空字典
    # print(dic5)
    # del dic5['name'] #删除字典中指定键值对
    # print(dic5)
    
    
    # print(dic5.pop('age')) #删除字典中指定键值对,并返回该键值对的值
    # ret=dic5.pop('age')
    # print(ret)
    # print(dic5)
    
    # a = dic5.popitem() #随机删除某组键值对,并以元组方式返回值
    # print(a, dic5)
    
    # del dic5        #删除整个字典
    # print(dic5)
    
    
    #5 其他操作以及涉及到的方法
    
    
    # dic6=dict.fromkeys(['host1','host2','host3'],'test')
    # print(dic6)#{'host3': 'test', 'host1': 'test', 'host2': 'test'}
    #
    # dic6['host2']='abc'
    # print(dic6)
    
    # dic6=dict.fromkeys(['host1','host2','host3'],['test1','tets2'])
    # print(dic6)#{'host2': ['test1', 'tets2'], 'host3': ['test1', 'tets2'], 'host1': ['test1', 'tets2']}
    #
    # dic6['host2'][1]='test3'
    # print(dic6)#{'host3': ['test1', 'test3'], 'host2': ['test1', 'test3'], 'host1': ['test1', 'test3']}
    
    
    
    
    # av_catalog = {
    #     "欧美":{
    #         "www.youporn.com": ["很多免费的,世界最大的","质量一般"],
    #         "www.pornhub.com": ["很多免费的,也很大","质量比yourporn高点"],
    #         "letmedothistoyou.com": ["多是自拍,高质量图片很多","资源不多,更新慢"],
    #         "x-art.com":["质量很高,真的很高","全部收费,屌比请绕过"]
    #     },
    #     "日韩":{
    #         "tokyo-hot":["质量怎样不清楚,个人已经不喜欢日韩范了","听说是收费的"]
    #     },
    #     "大陆":{
    #         "1024":["全部免费,真好,好人一生平安","服务器在国外,慢"]
    #     }
    # }
    
    # av_catalog['欧美']["www.youporn.com"][1]='高清午马'
    
    
    
    dic={5:'555',2:'666',4:'444'}
    # dic.has_keys(5)
    # print(5 in dic)
    # print(sorted(dic.items()))
    # dic5={'name': 'alex', 'age': 18}
    
    
    # for i in dic5:
    #     print(i,dic5[i])+
    
    # for i,v in dic5.items():
    #     print(i,v)
    
    
    
    #String 操作
    
    # a="Let's go "
    # print(a)
    # 1   * 重复输出字符串
    # print('hello'*20)
    
    # 2 [] ,[:] 通过索引获取字符串中字符,这里和列表的切片操作是相同的,具体内容见列表
    # print('helloworld'[2:])
    
    #关键字 in查看内容是否在in后面中出现过
    # print(123 in [23,45,123])
    # print('e2l' in 'hello')
    
    # 4 %   格式字符串
    # print('alex is a good teacher')
    # print('%s is a good teacher'%'alex')
    
    #5
    # a='123'
    # b='abc'
    # d='44'
    # # # c=a+b
    # # # print(c)     #可以通过+号将字符串进行拼接
    # #
    # c= ''.join([a,b,d])    #也可以通过符号拼接符join,将字符串先封存在列表里,转化成字符串
    # print(c)
    
    
    
    # String的内置方法
    
    # st='hello kitty {name} is {age}'
    #
    # print(st.count('l'))       #  统计元素个数
    # print(st.capitalize())     #  首字母大写
    
    # print(st.center(50,'#'))   #  居中
    # print('My tLtle'.ljust(50,'*'))
    # print('My tLtle'.rjust(50,'*'))
    
    # st='hel	lo kitty '
    # print(st.endswith('tty3')) #  判断是否以某个内容结尾
    # print(st.startswith('he')) #  判断是否以某个内容开头
    
    # st='hel	lo kitty '
    # print(st.expandtabs(tabsize=20))    #控制	长度
    # print(st.find('t'))        #  查找到第一个元素,并将索引值返回
    # print(st.index('t'))          #index索引没有发现值的话,就会报错
    
    # print(st.format(name='alex',age=37))  # 通过赋值的方式格式化输出的另一种方式   待定:?:{}
    # print(st.format_map({'name':'alex','age':22}))  #通过字典的方式格式化输出
    
    
    # print('asd'.isalnum()) #包含数字跟字母的字符串
    # print('12632178'.isdecimal())  #十进制
    # print('1269999.uuuu'.isnumeric())
    # print('abc'.isidentifier())   #是否是非法字符
    # print('Abc'.islower())
    # print('ABC'.isupper())
    # print('  e'.isspace())  #是否空格
    # print('My title'.istitle())
    # print('My tLtle'.lower())
    # print('My tLtle'.upper())
    # print('My tLtle'.swapcase())   #大写变小写,小写变大写
    
    # print('	My tLtle
    '.strip())   #将空格符和换行符去掉
    # print('	My tLtle
    '.lstrip())   #只去掉左边的
    # print('	My tLtle
    '.rstrip())
    # print('ok')
    
    # print('My title title'.replace('itle','lesson',1))
    # print('My title title'.rfind('t'))
    # print('My title title'.split('i',1))  #分割
    # print('My title title'.title())
    
    
    #摘一些重要的字符串方法
    #1 print(st.count('l'))
    # print(st.center(50,'#'))   #  居中
    # print(st.startswith('he')) #  判断是否以某个内容开头
    # print(st.find('t'))
    # print(st.format(name='alex',age=37))  # 格式化输出的另一种方式   待定:?:{}
    # print('My tLtle'.lower())
    # print('My tLtle'.upper())
    # print('	My tLtle
    '.strip())
    # print('My title title'.replace('itle','lesson',1))  #替换1次
    # print('My title title'.split('i',1))
    

      

  • 相关阅读:
    hdfs校验和
    hdfs读写策略
    hdfs架构
    hdfs数据块
    元数据
    集群的创建
    jQuery_DOM操作
    jQuery_简介_选择器
    Ajax
    MySQL整理_2_数据库操作
  • 原文地址:https://www.cnblogs.com/minkillmax/p/8438312.html
Copyright © 2011-2022 走看看