python 學習1.0

來源:互聯網
上載者:User

標籤:下標   內容   刪除   其他   ever   key   反向   python   post   

列表: [1,[2,‘three‘],4]   字典 {‘food’: ‘spam‘, ‘taste‘: ‘yum‘}   元組  (1, ‘spam‘, 4, ‘u‘)

檔案  myfile=open(‘eggs‘, ‘r‘)

 python 包括一些數學模組,在使用的時候注意載入相應的工具包,比如說 import math, import random等等

1.字串 下標是從0開始的,有反向索引, -1表示最右邊的一位,比如s=‘spam‘, s[-1]=‘m‘, 也可以是 s[len(s)-1]

二.列表

1.列表的切片以及索引等操作跟字串很像

2.列表特定的操作append在列表後面加東西,pop在列表裡面刪除內容,可以加上索引

3.sort操作對列表內容進行排序,reverse對列表內容反序

4.列表的嵌套,對其進行矩陣的實現

5.列表解析: 例如提取矩M第二列的內容,col2=[key[1] for key in M]

三.字典“:索引值對

四.元組:像字串一樣,但是具有不可變性  

五.檔案: 開啟open,read,write

六.其他:

decimal決定精度

 

python 學習1.0

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.