数据类型的一些方法

统计3出现了多少次
l=[1,2,3,3,3]
print(l.count(3))


一,整型,int
     记录年龄等整数
     age =18  age=int(18)
     数据类型转换
     n = int('12344445')
     必须纯数字
     不可变类型   

二.浮点类型,float
     age = 2.33  age = float(2.33)
     也是不可变类型
    
三.进制转换
     print(hex(11))
     print(bin(11))
     print(oct(11))

四.字符串
     name = 'kevin'
     name = str(kevin)
     1.按索引取值
         msg ='apple'
         print(msg[0])
         print(msg[-1])
     2.切片
         msg ='apple'
         print(msg[0:5:1])正取步长为1
         print(msg[::-1])反取步长为-1
     3.长度
         len()
     4.成员运算
         in 和  not in
     5.移除空白
         移除左右两边的空白
         msg= '***sdf***'
         msg.strip('*')
            
     6.切分split,rsplit(右边开始),lsplit(左边开始)
         以什么分割,返回一个列表
         info = 'dsf:sdf:sdfSDF'
         print(info.split(":"))
         用冒号拼接 只能是字符串
         res = info.split(":")
         print(":".join(res))
        
     7.循环
         msg='hello'
         for i in msg:
         print(i)
        
     8.替换replace
         msg = "sad tt suu"
         print(msg.replace("s","a"))
    
     9、判断是否是纯数字
         msg = '1233334'
         print(msg.isdigit())
    
     10.format
         res = '{} {} {}'.format('apple',23,3)
         print(res)
         res = '{1} {0} {1}'.format(7,9,6)
         print(res)
         res='{a}{b}{c}'.format(a=1,b=2,c=3)
         print(res)
        
    
    
    
五,列表
     类似于字符串
    
     增加
     append  添加在末尾
     insert  根据索引添加
     extend 追加多个
     删除
     del   都可以用
     remove  列表用
     pop   删除后并返回
    
     改
     a[0]=2
    
     查
     in  not in   切片