python 數據類型 變量

變量:

    可變:list dictionary

    不可變:string 數字 元組

訪問順序:

    直接訪問:數字

    順序訪問:字符串, 列表,列表

    映射(速度快,佔用空間大):字典

存放元素個數:

    容器類型: list, tuple, dictionary

    原子類型:數字 字符串

集合:{} #區別字典

    不同元素(去重複)

    無序

    元素爲不可變類型

    add()   pop()  remove() discard()

    交集:intersection()      &

    並集: union()      |

                update() #更新多個值

    差集: difference()     -    difference_update()

    交叉補集:symmetric_difference()    ^

    isdisjoint()

    issubset()   issuperset()

    frozenset()

字符串格式化:

‘my %s is %s’%('book','here')
l = 'i am %(name)s ' % name  #括號內標記,無影響

分隔符

print('root','0','0',sep = ':')


    

發佈了88 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章