zoukankan      html  css  js  c++  java
  • python 常用数据类型及操作方法

    #python数据类型
    a = None  #什么都没有
    
    b = True  #boolean类型
    
    c = 12    #int
    
    d = 12.33 #float
    
    e = "sdfs1122,,"  #字符串
    
    #元祖特征:值不可修改
    f = (1,2,3,"dd")
    print(f)
    
    #列表特征:值可修改、允许重复、可以储存任意数据类型的集合
    g = [1,2,3,4,"dd"]
    
    g.append(5)  #增
    g.remove(1)  #删
    g[2]=3       #改
    print(g[2])  #查
    print(g[-1])
    print(g[0:-1])
    
    '''转换类型'''
    tu=tuple(g)
    st=str(g)
    se=set(g)
    
    #字典特征:键值对形式、无序的、key不能重复、没有索引
    h = {"a":12,
         "b":18}
    
    h["c"]=19   #增
    del(h["b"]) #删
    h["a"]=11    #改
    print(h["a"])#查
    
    '''转换类型'''
    li=list(h)
    tu=tuple(h)
    st=str(h)
    se=set(h)
    
    #集合:set(自动去重;无序;没有下标索引;不能做切片操作)
    i = {1,2,3,"jj"}
    
    i.add(4)   #增
    i.remove(1)#删
    '''改:不可变类型无法修改元素'''
    print(i)   #查
    
    '''集合转换类型'''
    li = list(i)
    tu = tuple(i)
    st = str(i)
    

      

  • 相关阅读:
    SET TRANSACTION
    SET SESSION AUTHORIZATION
    SET CONSTRAINTS
    SET
    services
    send, sendto, sendmsg
    并列句分析
    cURL 学习笔记与总结(3)模拟登录博客园并下载个人随笔首页
    SQLServer2019安装教程
    Java实现 LeetCode 85 最大矩形
  • 原文地址:https://www.cnblogs.com/onelove1/p/13780466.html
Copyright © 2011-2022 走看看