美文网首页
python中的数据类型

python中的数据类型

作者: tenro | 来源:发表于2019-10-30 18:45 被阅读0次

    Number型

    整数(int)              #16
    浮点数(float)        #16.8
    布尔值 # true  false
    复数(complex)       #1 + 2j
    
    字符串             #'string'
    
    空值  #none
    常量 #PI=3.14159
    
    列表(list)  [1, 2, 3, 4]   #可以通过方法将列表里面的元素进行操作
    元祖(tuple)  (1, 2, 3)   #元祖定下来是无法操作里面的元素
    字典(dic)
    

    字符串的编码

    order() #将中文转换成编码
    chr() #将编码转换成中文
    

    计算操作

     / # 除以
    // #整除
    %  #取余
    

    格式化

     占位符    替换内容
      %d        整数
      %f        浮点数
      %s        字符串
      %x        十六进制整数
    
    print("hello, %s" % 'world')
    print("hi! %s, you have %d." % ('tenro', 1000000))
    print("亲爱的%s您好!您%d月的话费是%d,当前可用余额是%.2f." % ('小康', 8, 99, 33.4))
    

    相关文章

      网友评论

          本文标题:python中的数据类型

          本文链接:https://www.haomeiwen.com/subject/sakfwftx.html