python學習感悟第3節

來源:互聯網
上載者:User

標籤:tab鍵   通過   需要   cat   空格   ndt   name   key   學習   

在繼列表的學習之後,進行了元組的學習。元組和列表功能相似,只是元組不能進行修改,所以元組又叫唯讀列表。

下面列舉的是一系列的字串操作:

name.capitalize()  #首字母大寫

name.count("a")   #數列表中有幾個a

name.center(5o,"-")  #意思是一共列印50個字元,不夠用“-”補

name.endwith("ex") #看字串是否以ex結尾

name.expandtabs(tabsize=30)   #將tab鍵轉換成30個空格

下面學習的是字典:

在字典中不是通過位置進行索引的,字典是無序的,因為其無下標,字典不需要下標,因為其有key

info={

      ‘stu1101‘="A"

      ‘stu1102‘="B"

      ‘stu1103‘="C"

}

print(info)

(1)查

法1):print(info["stu1101"])   #通過鍵尋找

法2):print(info.get(‘stu1103‘))

(2)改

info["stu1101"]="wu"

(3)增

info["stu1104"]="c"

(4)刪

1)法1:del info["stu1101"]

2)法2:info.pop("stu1101")

#判斷一個字典中有沒有

print(‘stu1104‘ in info)

#多級字典的嵌套

catalog={

" "={

"key":[list]

}

" "={

}

}

info.value()  #列印值

info.key()  #列印鍵

 

python學習感悟第3節

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.